diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-06-23 21:17:24 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-06-23 21:17:24 +0000 |
commit | 14e200d14d02fd36fd1ff1fd02b9b150ce170db8 (patch) | |
tree | 064e9770be840f37d5bc39b5a51a16cb0fbd3d90 /libcxx/test | |
parent | 60c16eb7f537dcabce2aa9c0f3305d7f44287cf5 (diff) | |
download | bcm5719-llvm-14e200d14d02fd36fd1ff1fd02b9b150ce170db8.tar.gz bcm5719-llvm-14e200d14d02fd36fd1ff1fd02b9b150ce170db8.zip |
Implement full support for non-pointer pointers in custom allocators for deque.
llvm-svn: 184673
Diffstat (limited to 'libcxx/test')
46 files changed, 915 insertions, 275 deletions
diff --git a/libcxx/test/containers/sequences/deque/deque.capacity/access.pass.cpp b/libcxx/test/containers/sequences/deque/deque.capacity/access.pass.cpp index 5fa16875ae6..1215f9582b0 100644 --- a/libcxx/test/containers/sequences/deque/deque.capacity/access.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.capacity/access.pass.cpp @@ -24,7 +24,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -35,7 +38,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -48,7 +51,26 @@ make(int size, int start = 0 ) int main() { { - std::deque<int> c = make(10); + std::deque<int> c = make<std::deque<int> >(10); + for (unsigned i = 0; i < 10; ++i) + assert(c[i] == i); + for (unsigned i = 0; i < 10; ++i) + assert(c.at(i) == i); + assert(c.front() == 0); + assert(c.back() == 9); + } + { + const std::deque<int> c = make<std::deque<int> >(10); + for (unsigned i = 0; i < 10; ++i) + assert(c[i] == i); + for (unsigned i = 0; i < 10; ++i) + assert(c.at(i) == i); + assert(c.front() == 0); + assert(c.back() == 9); + } +#if __cplusplus >= 201103L + { + std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10); for (unsigned i = 0; i < 10; ++i) assert(c[i] == i); for (unsigned i = 0; i < 10; ++i) @@ -57,7 +79,7 @@ int main() assert(c.back() == 9); } { - const std::deque<int> c = make(10); + const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10); for (unsigned i = 0; i < 10; ++i) assert(c[i] == i); for (unsigned i = 0; i < 10; ++i) @@ -65,4 +87,5 @@ int main() assert(c.front() == 0); assert(c.back() == 9); } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/libcxx/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp index 0043c60a458..fee4a8955c6 100644 --- a/libcxx/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1, int size) +test(C& c1, int size) { - typedef std::deque<int> C; - typedef C::const_iterator CI; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); c1.resize(size); assert(c1.size() == size); @@ -51,21 +54,33 @@ test(std::deque<int>& c1, int size) assert(*i == 0); } +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::const_iterator CI; - C c1 = make(N, start); + typedef typename C::const_iterator CI; + C c1 = make<C>(N, start); test(c1, M); } int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int> >(rng[i], rng[j], rng[k]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); + testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/libcxx/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp index fbc62e3b653..b05bffae93e 100644 --- a/libcxx/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1, int size, int x) +test(C& c1, int size, int x) { - typedef std::deque<int> C; - typedef C::const_iterator CI; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); c1.resize(size, x); assert(c1.size() == size); @@ -51,21 +54,33 @@ test(std::deque<int>& c1, int size, int x) assert(*i == x); } +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::const_iterator CI; - C c1 = make(N, start); + typedef typename C::const_iterator CI; + C c1 = make<C>(N, start); test(c1, M, -10); } int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int> >(rng[i], rng[j], rng[k]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); + testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp b/libcxx/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp index 8e2404794ba..b823ace58be 100644 --- a/libcxx/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,28 +38,40 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1) +test(C& c1) { - std::deque<int> s = c1; + C s = c1; c1.shrink_to_fit(); assert(c1 == s); } +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - typedef C::const_iterator CI; - C c1 = make(N, start); + typedef typename C::const_iterator CI; + C c1 = make<C>(N, start); test(c1); } int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/alloc.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/alloc.pass.cpp index 3e635b1dbbb..e23e50003aa 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/alloc.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/alloc.pass.cpp @@ -16,6 +16,7 @@ #include "../../../test_allocator.h" #include "../../../NotConstructible.h" +#include "../../../min_allocator.h" template <class T, class Allocator> void @@ -30,4 +31,8 @@ int main() { test<int>(std::allocator<int>()); test<NotConstructible>(test_allocator<NotConstructible>(3)); +#if __cplusplus >= 201103L + test<int>(min_allocator<int>()); + test<NotConstructible>(min_allocator<NotConstructible>{}); +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp index 9788c6f0028..27b8bbbed5f 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include <deque> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::deque<int> d; d.assign({3, 4, 5, 6}); assert(d.size() == 4); @@ -24,5 +27,17 @@ int main() assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::deque<int, min_allocator<int>> d; + d.assign({3, 4, 5, 6}); + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp index da5a61630b4..0c60d75a8e8 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp @@ -16,8 +16,10 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -28,7 +30,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -38,8 +40,9 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1, const std::deque<int>& c2) +test(C& c1, const C& c2) { std::size_t c1_osize = c1.size(); c1.assign(c2.begin(), c2.end()); @@ -47,22 +50,22 @@ test(std::deque<int>& c1, const std::deque<int>& c2) assert(c1 == c2); } +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; - C c1 = make(N, start); - C c2 = make(M); + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(c1, c2); } +template <class C> void -testI(std::deque<int>& c1, const std::deque<int>& c2) +testI(C& c1, const C& c2) { - typedef std::deque<int> C; - typedef C::const_iterator CI; + typedef typename C::const_iterator CI; typedef input_iterator<CI> ICI; std::size_t c1_osize = c1.size(); c1.assign(ICI(c2.begin()), ICI(c2.end())); @@ -70,24 +73,37 @@ testI(std::deque<int>& c1, const std::deque<int>& c2) assert(c1 == c2); } +template <class C> void testNI(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; - C c1 = make(N, start); - C c2 = make(M); + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + C c1 = make<C>(N, start); + C c2 = make<C>(M); testI(c1, c2); } int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); - testNI(1500, 2000, 1000); + testN<std::deque<int> >(rng[i], rng[j], rng[k]); + testNI<std::deque<int> >(1500, 2000, 1000); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]); + testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp index b92ba136a3d..7401f042efb 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp @@ -15,8 +15,10 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -27,7 +29,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -37,11 +39,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1, int size, int v) +test(C& c1, int size, int v) { - typedef std::deque<int> C; - typedef C::const_iterator CI; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); c1.assign(size, v); assert(c1.size() == size); @@ -50,22 +52,34 @@ test(std::deque<int>& c1, int size, int v) assert(*i == v); } +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; - C c1 = make(N, start); + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + C c1 = make<C>(N, start); test(c1, M, -10); } int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); + testN<std::deque<int> >(rng[i], rng[j], rng[k]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/copy.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/copy.pass.cpp index b986f59cecc..4029bcc724b 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/copy.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/copy.pass.cpp @@ -14,6 +14,7 @@ #include <deque> #include <cassert> #include "../../../test_allocator.h" +#include "../../../min_allocator.h" template <class C> void @@ -44,4 +45,17 @@ int main() assert(v2.get_allocator() == other_allocator<int>(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; + int* an = ab + sizeof(ab)/sizeof(ab[0]); + test(std::deque<int, min_allocator<int>>(ab, an)); + } + { + std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>()); + std::deque<int, min_allocator<int> > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == v.get_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp index c5b20bf0247..156e011343c 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp @@ -15,6 +15,7 @@ #include <cassert> #include "../../../test_allocator.h" +#include "../../../min_allocator.h" template <class C> void @@ -39,4 +40,12 @@ int main() test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)), other_allocator<int>(4)); } +#if __cplusplus >= 201103L + { + int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; + int* an = ab + sizeof(ab)/sizeof(ab[0]); + test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()), + min_allocator<int>()); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/default.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/default.pass.cpp index 4ee40bc6556..910421c6fc3 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/default.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/default.pass.cpp @@ -16,6 +16,7 @@ #include "../../../stack_allocator.h" #include "../../../NotConstructible.h" +#include "../../../min_allocator.h" template <class T, class Allocator> void @@ -29,4 +30,8 @@ int main() { test<int, std::allocator<int> >(); test<NotConstructible, stack_allocator<NotConstructible, 1> >(); +#if __cplusplus >= 201103L + test<int, min_allocator<int> >(); + test<NotConstructible, min_allocator<NotConstructible> >(); +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp index 26819099151..537ded5e034 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp @@ -14,14 +14,28 @@ #include <deque> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::deque<int> d = {3, 4, 5, 6}; assert(d.size() == 4); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::deque<int, min_allocator<int>> d = {3, 4, 5, 6}; + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp index 0b5fc0208d3..66ee3abdaeb 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp @@ -15,10 +15,12 @@ #include <cassert> #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); assert(d.size() == 4); @@ -26,5 +28,17 @@ int main() assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); + assert(d.get_allocator() == min_allocator<int>()); + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp index a43c344cb9b..1a85871f9d5 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp @@ -16,6 +16,7 @@ #include "../../../stack_allocator.h" #include "test_iterators.h" +#include "../../../min_allocator.h" template <class InputIterator> void @@ -55,4 +56,7 @@ int main() test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an)); test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an)); test<stack_allocator<int, 4096> >(ab, an); +#if __cplusplus >= 201103L + test<min_allocator<int> >(ab, an); +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp index cfa86a94e88..2070f4a957a 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp @@ -17,6 +17,7 @@ #include "test_iterators.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" template <class InputIterator, class Allocator> void @@ -41,4 +42,10 @@ int main() test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4)); test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5)); test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6)); +#if __cplusplus >= 201103L + test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>()); + test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>()); + test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>()); + test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>()); +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/move.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/move.pass.cpp index 67a515b2803..5764c61d54e 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/move.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/move.pass.cpp @@ -16,6 +16,7 @@ #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -50,5 +51,22 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == c1.get_allocator()); } +#if __cplusplus >= 201103L + { + int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; + int* an = ab + sizeof(ab)/sizeof(ab[0]); + typedef min_allocator<MoveOnly> A; + std::deque<MoveOnly, A> c1(A{}); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque<MoveOnly, A> c2(A{}); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque<MoveOnly, A> c3 = std::move(c1); + assert(c2 == c3); + assert(c1.size() == 0); + assert(c3.get_allocator() == c1.get_allocator()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp index 0d6ca269013..def1fc396f7 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp @@ -16,6 +16,7 @@ #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -65,5 +66,22 @@ int main() assert(c3.get_allocator() == A(3)); assert(c1.size() != 0); } +#if __cplusplus >= 201103L + { + int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; + int* an = ab + sizeof(ab)/sizeof(ab[0]); + typedef min_allocator<MoveOnly> A; + std::deque<MoveOnly, A> c1(A{}); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque<MoveOnly, A> c2(A{}); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque<MoveOnly, A> c3(std::move(c1), A()); + assert(c2 == c3); + assert(c3.get_allocator() == A()); + assert(c1.size() == 0); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp index 3990af3f458..a9e760f2fbd 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp @@ -16,6 +16,7 @@ #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -68,5 +69,23 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == A(5)); } +#if __cplusplus >= 201103L + { + int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; + int* an = ab + sizeof(ab)/sizeof(ab[0]); + typedef min_allocator<MoveOnly> A; + std::deque<MoveOnly, A> c1(A{}); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque<MoveOnly, A> c2(A{}); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque<MoveOnly, A> c3(A{}); + c3 = std::move(c1); + assert(c2 == c3); + assert(c1.size() == 0); + assert(c3.get_allocator() == A()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp index 9c7561a7356..bb169c1f836 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp @@ -14,6 +14,7 @@ #include <deque> #include <cassert> #include "../../../test_allocator.h" +#include "../../../min_allocator.h" template <class C> void @@ -45,4 +46,18 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(5)); } +#if __cplusplus >= 201103L + { + int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; + int* an = ab + sizeof(ab)/sizeof(ab[0]); + test(std::deque<int, min_allocator<int>>(ab, an)); + } + { + std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>()); + std::deque<int, min_allocator<int> > l2(l, min_allocator<int>()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator<int>()); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp index 7ba826b9296..577b51cf05f 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include <deque> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::deque<int> d; d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -24,5 +27,17 @@ int main() assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::deque<int, min_allocator<int>> d; + d = {3, 4, 5, 6}; + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp index af8e8b866eb..6d0bf424829 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp @@ -16,6 +16,7 @@ #include "../../../stack_allocator.h" #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" template <class T, class Allocator> void @@ -52,4 +53,7 @@ int main() test<DefaultOnly, std::allocator<DefaultOnly> >(4096); test<DefaultOnly, std::allocator<DefaultOnly> >(4097); test<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095); +#if __cplusplus >= 201103L + test<DefaultOnly, min_allocator<DefaultOnly> >(4095); +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/size_value.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/size_value.pass.cpp index 7a4df266559..782c0ed5d0d 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/size_value.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/size_value.pass.cpp @@ -15,6 +15,7 @@ #include <cassert> #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" template <class T, class Allocator> void @@ -44,4 +45,7 @@ int main() test<int, std::allocator<int> >(4096, 1165); test<int, std::allocator<int> >(4097, 157); test<int, stack_allocator<int, 4096> >(4095, 90); +#if __cplusplus >= 201103L + test<int, min_allocator<int> >(4095, 90); +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp index 49cc9b58fde..c61ce155e6d 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp @@ -14,6 +14,8 @@ #include <deque> #include <cassert> +#include "../../../min_allocator.h" + template <class T, class Allocator> void test(unsigned n, const T& x, const Allocator& a) @@ -30,6 +32,7 @@ test(unsigned n, const T& x, const Allocator& a) int main() { + { std::allocator<int> a; test(0, 5, a); test(1, 10, a); @@ -43,4 +46,22 @@ int main() test(4095, 78, a); test(4096, 1165, a); test(4097, 157, a); + } +#if __cplusplus >= 201103L + { + min_allocator<int> a; + test(0, 5, a); + test(1, 10, a); + test(10, 11, a); + test(1023, -11, a); + test(1024, 25, a); + test(1025, 0, a); + test(2047, 110, a); + test(2048, -500, a); + test(2049, 654, a); + test(4095, 78, a); + test(4096, 1165, a); + test(4097, 157, a); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp index a829e88ca81..d332bb45d72 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp @@ -15,10 +15,12 @@ #include <cassert> #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -std::deque<Emplaceable> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -29,7 +31,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<Emplaceable> c(init); + C c(init); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -39,12 +41,12 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<Emplaceable>& c1) +test(int P, C& c1) { - typedef std::deque<Emplaceable> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5)); assert(i == c1.begin() + P); @@ -53,17 +55,17 @@ test(int P, std::deque<Emplaceable>& c1) assert(*i == Emplaceable(1, 2.5)); } +template <class C> void testN(int start, int N) { - typedef std::deque<Emplaceable> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1); } } @@ -71,7 +73,7 @@ testN(int start, int N) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1); } } @@ -79,7 +81,7 @@ testN(int start, int N) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1); } } @@ -90,10 +92,21 @@ testN(int start, int N) int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<Emplaceable> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp index 633cbf9bfea..892418e935f 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp @@ -15,10 +15,12 @@ #include <cassert> #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -std::deque<Emplaceable> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -29,7 +31,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<Emplaceable> c(init); + C c(init); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -39,11 +41,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<Emplaceable>& c1) +test(C& c1) { - typedef std::deque<Emplaceable> C; - typedef C::iterator I; + typedef typename C::iterator I; std::size_t c1_osize = c1.size(); c1.emplace_back(Emplaceable(1, 2.5)); assert(c1.size() == c1_osize + 1); @@ -52,11 +54,11 @@ test(std::deque<Emplaceable>& c1) assert(*--i == Emplaceable(1, 2.5)); } +template <class C> void testN(int start, int N) { - typedef std::deque<Emplaceable> C; - C c1 = make(N, start); + C c1 = make<C>(N, start); test(c1); } @@ -65,10 +67,21 @@ testN(int start, int N) int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<Emplaceable> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp index d0077341a90..6eebfa8e1a1 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp @@ -15,10 +15,12 @@ #include <cassert> #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -std::deque<Emplaceable> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -29,7 +31,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<Emplaceable> c(init); + C c(init); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -39,11 +41,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<Emplaceable>& c1) +test(C& c1) { - typedef std::deque<Emplaceable> C; - typedef C::iterator I; + typedef typename C::iterator I; std::size_t c1_osize = c1.size(); c1.emplace_front(Emplaceable(1, 2.5)); assert(c1.size() == c1_osize + 1); @@ -52,11 +54,11 @@ test(std::deque<Emplaceable>& c1) assert(*i == Emplaceable(1, 2.5)); } +template <class C> void testN(int start, int N) { - typedef std::deque<Emplaceable> C; - C c1 = make(N, start); + C c1 = make<C>(N, start); test(c1); } @@ -65,10 +67,21 @@ testN(int start, int N) int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<Emplaceable> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp index 1cec0308067..1b4da3faa9d 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<int>& c1) +test(int P, C& c1) { - typedef std::deque<int> C; - typedef C::iterator I; + typedef typename C::iterator I; assert(P < c1.size()); std::size_t c1_osize = c1.size(); I i = c1.erase(c1.cbegin() + P); @@ -54,23 +57,34 @@ test(int P, std::deque<int>& c1) assert(*i == j); } +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; int pstep = std::max(N / std::max(std::min(N, 10), 1), 1); for (int p = 0; p < N; p += pstep) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(p, c1); } } int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp index 20d03f29438..37b6c1c157c 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<int>& c1, int size) +test(int P, C& c1, int size) { - typedef std::deque<int> C; - typedef C::iterator I; + typedef typename C::iterator I; assert(P + size <= c1.size()); std::size_t c1_osize = c1.size(); I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size)); @@ -54,17 +57,17 @@ test(int P, std::deque<int>& c1, int size) assert(*i == j); } +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; int pstep = std::max(N / std::max(std::min(N, 10), 1), 1); for (int p = 0; p <= N; p += pstep) { int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1); for (int s = 0; s <= N - p; s += sstep) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(p, c1, s); } } @@ -72,9 +75,20 @@ testN(int start, int N) int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp index 7696553f1b6..487db6bd564 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include <deque> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::deque<int> d(10, 1); std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); assert(d.size() == 14); @@ -35,5 +38,26 @@ int main() assert(d[11] == 1); assert(d[12] == 1); assert(d[13] == 1); + } + { + std::deque<int, min_allocator<int>> d(10, 1); + std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); + assert(d.size() == 14); + assert(i == d.begin() + 2); + assert(d[0] == 1); + assert(d[1] == 1); + assert(d[2] == 3); + assert(d[3] == 4); + assert(d[4] == 5); + assert(d[5] == 6); + assert(d[6] == 1); + assert(d[7] == 1); + assert(d[8] == 1); + assert(d[9] == 1); + assert(d[10] == 1); + assert(d[11] == 1); + assert(d[12] == 1); + assert(d[13] == 1); + } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp index 7132ff4c6a3..1cf507c5d74 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp @@ -18,8 +18,10 @@ #include "test_iterators.h" #include "../../../MoveOnly.h" #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -30,7 +32,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -40,12 +42,12 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<int>& c1, const std::deque<int>& c2) +test(int P, C& c1, const C& c2) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; typedef bidirectional_iterator<CI> BCI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); @@ -61,18 +63,18 @@ test(int P, std::deque<int>& c1, const std::deque<int>& c2) assert(*i == j); } +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(i, c1, c2); } } @@ -80,8 +82,8 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(i, c1, c2); } } @@ -89,8 +91,8 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(i, c1, c2); } } @@ -98,8 +100,8 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(i, c1, c2); } } @@ -107,8 +109,8 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(i, c1, c2); } } @@ -116,19 +118,19 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); test(i, c1, c2); } } } +template <class C> void -testI(int P, std::deque<int>& c1, const std::deque<int>& c2) +testI(int P, C& c1, const C& c2) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; typedef input_iterator<CI> ICI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end())); @@ -144,18 +146,18 @@ testI(int P, std::deque<int>& c1, const std::deque<int>& c2) assert(*i == j); } +template <class C> void testNI(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); testI(i, c1, c2); } } @@ -163,8 +165,8 @@ testNI(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); testI(i, c1, c2); } } @@ -172,8 +174,8 @@ testNI(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); testI(i, c1, c2); } } @@ -181,8 +183,8 @@ testNI(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); testI(i, c1, c2); } } @@ -190,19 +192,20 @@ testNI(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); testI(i, c1, c2); } } } +template <class C> void test_move() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > c; - typedef std::deque<MoveOnly>::const_iterator CI; + C c; + typedef typename C::const_iterator CI; { MoveOnly mo(0); typedef MoveOnly* I; @@ -224,12 +227,28 @@ test_move() int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); - testNI(1500, 2000, 1000); - test_move(); + testN<std::deque<int> >(rng[i], rng[j], rng[k]); + testNI<std::deque<int> >(1500, 2000, 1000); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >(); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]); + testNI<std::deque<int> >(1500, 2000, 1000); + test_move<std::deque<MoveOnly, min_allocator<MoveOnly> > >(); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp index 03693846ae6..e1cac32357e 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp @@ -15,10 +15,12 @@ #include <cassert> #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -std::deque<MoveOnly> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -29,7 +31,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<MoveOnly> c(init); + C c(init); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -39,12 +41,12 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<MoveOnly>& c1, int x) +test(int P, C& c1, int x) { - typedef std::deque<MoveOnly> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, MoveOnly(x)); assert(i == c1.begin() + P); @@ -59,17 +61,17 @@ test(int P, std::deque<MoveOnly>& c1, int x) assert(*i == MoveOnly(j)); } +template <class C> void testN(int start, int N) { - typedef std::deque<MoveOnly> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, -10); } } @@ -77,7 +79,7 @@ testN(int start, int N) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, -10); } } @@ -85,7 +87,7 @@ testN(int start, int N) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, -10); } } @@ -96,10 +98,21 @@ testN(int start, int N) int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<MoveOnly> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp index 633055c7f4c..71129bf98e3 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,12 +38,12 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<int>& c1, int size, int x) +test(int P, C& c1, int size, int x) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, size, x); assert(i == c1.begin() + P); @@ -55,17 +58,17 @@ test(int P, std::deque<int>& c1, int size, int x) assert(*i == j); } +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, M, -10); } } @@ -73,7 +76,7 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, M, -10); } } @@ -81,7 +84,7 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, M, -10); } } @@ -89,7 +92,7 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, M, -10); } } @@ -97,22 +100,22 @@ testN(int start, int N, int M) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, M, -10); } } } +template <class C> void self_reference_test() { - typedef std::deque<int> C; - typedef C::const_iterator CI; + typedef typename C::const_iterator CI; for (int i = 0; i < 20; ++i) { for (int j = 0; j < 20; ++j) { - C c = make(20); + C c = make<C>(20); CI it = c.cbegin() + i; CI jt = c.cbegin() + j; c.insert(it, 5, *jt); @@ -131,11 +134,24 @@ self_reference_test() int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int> >(rng[i], rng[j], rng[k]); + self_reference_test<std::deque<int> >(); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); - self_reference_test(); + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]); + self_reference_test<std::deque<int, min_allocator<int>> >(); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp index cc9791c74ae..87be595b67b 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,12 +38,12 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(int P, std::deque<int>& c1, int x) +test(int P, C& c1, int x) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, x); assert(i == c1.begin() + P); @@ -55,17 +58,17 @@ test(int P, std::deque<int>& c1, int x) assert(*i == j); } +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, -10); } } @@ -73,7 +76,7 @@ testN(int start, int N) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, -10); } } @@ -81,22 +84,22 @@ testN(int start, int N) { if (0 <= i && i <= N) { - C c1 = make(N, start); + C c1 = make<C>(N, start); test(i, c1, -10); } } } +template <class C> void self_reference_test() { - typedef std::deque<int> C; - typedef C::const_iterator CI; + typedef typename C::const_iterator CI; for (int i = 0; i < 20; ++i) { for (int j = 0; j < 20; ++j) { - C c = make(20); + C c = make<C>(20); CI it = c.cbegin() + i; CI jt = c.cbegin() + j; c.insert(it, *jt); @@ -115,10 +118,22 @@ self_reference_test() int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); - self_reference_test(); + testN<std::deque<int> >(rng[i], rng[j]); + self_reference_test<std::deque<int> >(); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + self_reference_test<std::deque<int, min_allocator<int>> >(); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp index 289264becdb..51812cf268f 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1) +test(C& c1) { - typedef std::deque<int> C; - typedef C::iterator I; + typedef typename C::iterator I; std::size_t c1_osize = c1.size(); c1.pop_back(); assert(c1.size() == c1_osize - 1); @@ -49,22 +52,33 @@ test(std::deque<int>& c1) assert(*i == j); } +template <class C> void testN(int start, int N) { if (N != 0) { - typedef std::deque<int> C; - C c1 = make(N, start); + C c1 = make<C>(N, start); test(c1); } } int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp index b359a54b996..17597abc7f5 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1) +test(C& c1) { - typedef std::deque<int> C; - typedef C::iterator I; + typedef typename C::iterator I; std::size_t c1_osize = c1.size(); c1.pop_front(); assert(c1.size() == c1_osize - 1); @@ -49,22 +52,33 @@ test(std::deque<int>& c1) assert(*i == j); } +template <class C> void testN(int start, int N) { if (N != 0) { - typedef std::deque<int> C; - C c1 = make(N, start); + C c1 = make<C>(N, start); test(c1); } } int main() { + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp index 056ee5568a1..cb7155a59f4 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp @@ -16,7 +16,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -27,7 +30,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -37,14 +40,15 @@ make(int size, int start = 0 ) return c; }; +template <class C> void test(int size) { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int j = 0; j < N; ++j) { - std::deque<int> c = make(size, rng[j]); - std::deque<int>::const_iterator it = c.begin(); + C c = make<C>(size, rng[j]); + typename C::const_iterator it = c.begin(); for (int i = 0; i < size; ++i, ++it) assert(*it == i); } @@ -52,8 +56,18 @@ void test(int size) int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int j = 0; j < N; ++j) + test<std::deque<int> >(rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; const int N = sizeof(rng)/sizeof(rng[0]); for (int j = 0; j < N; ++j) - test(rng[j]); + test<std::deque<int, min_allocator<int>> >(rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp index c6dab900d24..c60fdfc55d1 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp @@ -17,10 +17,12 @@ #include <cassert> #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -std::deque<MoveOnly> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -31,7 +33,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<MoveOnly> c(init); + C c(init); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -41,14 +43,15 @@ make(int size, int start = 0 ) return c; }; +template <class C> void test(int size) { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int j = 0; j < N; ++j) { - std::deque<MoveOnly> c = make(size, rng[j]); - std::deque<MoveOnly>::const_iterator it = c.begin(); + C c = make<C>(size, rng[j]); + typename C::const_iterator it = c.begin(); for (int i = 0; i < size; ++i, ++it) assert(*it == MoveOnly(i)); } @@ -59,9 +62,19 @@ void test(int size) int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; const int N = sizeof(rng)/sizeof(rng[0]); for (int j = 0; j < N; ++j) - test(rng[j]); + test<std::deque<MoveOnly> >(rng[j]); + } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int j = 0; j < N; ++j) + test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp index d5604d92d79..e3b2d98f7a5 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp @@ -14,7 +14,10 @@ #include <deque> #include <cassert> -std::deque<int> +#include "../../../min_allocator.h" + +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -25,7 +28,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -35,11 +38,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<int>& c1, int x) +test(C& c1, int x) { - typedef std::deque<int> C; - typedef C::iterator I; + typedef typename C::iterator I; std::size_t c1_osize = c1.size(); c1.push_front(x); assert(c1.size() == c1_osize + 1); @@ -51,19 +54,30 @@ test(std::deque<int>& c1, int x) assert(*i == j); } +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - C c1 = make(N, start); + C c1 = make<C>(N, start); test(c1, -10); } int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/libcxx/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp index 435de481303..650a9b8a050 100644 --- a/libcxx/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp @@ -15,10 +15,12 @@ #include <cassert> #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -std::deque<MoveOnly> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -29,7 +31,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<MoveOnly> c(init); + C c(init); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -39,11 +41,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void -test(std::deque<MoveOnly>& c1, int x) +test(C& c1, int x) { - typedef std::deque<MoveOnly> C; - typedef C::iterator I; + typedef typename C::iterator I; std::size_t c1_osize = c1.size(); c1.push_front(MoveOnly(x)); assert(c1.size() == c1_osize + 1); @@ -55,11 +57,11 @@ test(std::deque<MoveOnly>& c1, int x) assert(*i == MoveOnly(j)); } +template <class C> void testN(int start, int N) { - typedef std::deque<MoveOnly> C; - C c1 = make(N, start); + C c1 = make<C>(N, start); test(c1, -10); } @@ -68,10 +70,21 @@ testN(int start, int N) int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<MoveOnly> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/deque/deque.special/copy.pass.cpp b/libcxx/test/containers/sequences/deque/deque.special/copy.pass.cpp index c5ef688be52..e8bf4daf0b7 100644 --- a/libcxx/test/containers/sequences/deque/deque.special/copy.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.special/copy.pass.cpp @@ -19,8 +19,10 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -31,7 +33,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -41,16 +43,16 @@ make(int size, int start = 0 ) return c; }; +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; typedef random_access_iterator<I> RAI; typedef random_access_iterator<CI> RACI; typedef input_iterator<CI> ICI; - C c1 = make(N, start); - C c2 = make(N); + C c1 = make<C>(N, start); + C c2 = make<C>(N); assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end()); assert(c1 == c2); assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end()); @@ -67,9 +69,20 @@ void testN(int start, int N) int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp b/libcxx/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp index 7544ba82836..61681265908 100644 --- a/libcxx/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp @@ -19,8 +19,10 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -31,7 +33,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -41,15 +43,15 @@ make(int size, int start = 0 ) return c; }; +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; typedef random_access_iterator<I> RAI; typedef random_access_iterator<CI> RACI; - C c1 = make(N, start); - C c2 = make(N); + C c1 = make<C>(N, start); + C c2 = make<C>(N); assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin()); assert(c1 == c2); assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin()); @@ -66,9 +68,20 @@ void testN(int start, int N) int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.special/move.pass.cpp b/libcxx/test/containers/sequences/deque/deque.special/move.pass.cpp index c4d36513e8d..2da742f6d76 100644 --- a/libcxx/test/containers/sequences/deque/deque.special/move.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.special/move.pass.cpp @@ -19,8 +19,10 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -31,7 +33,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -41,15 +43,15 @@ make(int size, int start = 0 ) return c; }; +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; typedef random_access_iterator<I> RAI; typedef random_access_iterator<CI> RACI; - C c1 = make(N, start); - C c2 = make(N); + C c1 = make<C>(N, start); + C c2 = make<C>(N); assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end()); assert(c1 == c2); assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end()); @@ -66,9 +68,20 @@ void testN(int start, int N) int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.special/move_backward.pass.cpp b/libcxx/test/containers/sequences/deque/deque.special/move_backward.pass.cpp index b56bf721bcb..6fe094f7b48 100644 --- a/libcxx/test/containers/sequences/deque/deque.special/move_backward.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.special/move_backward.pass.cpp @@ -19,8 +19,10 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -31,7 +33,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -41,15 +43,15 @@ make(int size, int start = 0 ) return c; }; +template <class C> void testN(int start, int N) { - typedef std::deque<int> C; - typedef C::iterator I; - typedef C::const_iterator CI; + typedef typename C::iterator I; + typedef typename C::const_iterator CI; typedef random_access_iterator<I> RAI; typedef random_access_iterator<CI> RACI; - C c1 = make(N, start); - C c2 = make(N); + C c1 = make<C>(N, start); + C c2 = make<C>(N); assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin()); assert(c1 == c2); assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin()); @@ -66,9 +68,20 @@ void testN(int start, int N) int main() { + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + testN<std::deque<int> >(rng[i], rng[j]); + } +#if __cplusplus >= 201103L + { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) - testN(rng[i], rng[j]); + testN<std::deque<int, min_allocator<int> > >(rng[i], rng[j]); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/deque.special/swap.pass.cpp b/libcxx/test/containers/sequences/deque/deque.special/swap.pass.cpp index 795ab01421e..d4da735a408 100644 --- a/libcxx/test/containers/sequences/deque/deque.special/swap.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.special/swap.pass.cpp @@ -15,8 +15,10 @@ #include <deque> #include <cassert> #include "../../../test_allocator.h" +#include "../../../min_allocator.h" -std::deque<int> +template <class C> +C make(int size, int start = 0 ) { const int b = 4096 / sizeof(int); @@ -27,7 +29,7 @@ make(int size, int start = 0 ) init *= b; --init; } - std::deque<int> c(init, 0); + C c(init, 0); for (int i = 0; i < init-start; ++i) c.pop_back(); for (int i = 0; i < size; ++i) @@ -37,11 +39,11 @@ make(int size, int start = 0 ) return c; }; +template <class C> void testN(int start, int N, int M) { - typedef std::deque<int> C; - C c1 = make(N, start); - C c2 = make(M); + C c1 = make<C>(N, start); + C c2 = make<C>(M); C c1_save = c1; C c2_save = c2; swap(c1, c2); @@ -57,7 +59,7 @@ int main() for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - testN(rng[i], rng[j], rng[k]); + testN<std::deque<int> >(rng[i], rng[j], rng[k]); } { int a1[] = {1, 3, 7, 9, 10}; @@ -83,4 +85,26 @@ int main() assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A(1)); } +#if __cplusplus >= 201103L + { + int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; + const int N = sizeof(rng)/sizeof(rng[0]); + for (int i = 0; i < N; ++i) + for (int j = 0; j < N; ++j) + for (int k = 0; k < N; ++k) + testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]); + } + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + typedef min_allocator<int> A; + std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); + std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A()); + swap(c1, c2); + assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A()); + assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); + assert(c2.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/iterators.pass.cpp b/libcxx/test/containers/sequences/deque/iterators.pass.cpp index 7e38b86489f..ee5e96e8f9a 100644 --- a/libcxx/test/containers/sequences/deque/iterators.pass.cpp +++ b/libcxx/test/containers/sequences/deque/iterators.pass.cpp @@ -20,8 +20,11 @@ #include <iterator> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef std::deque<int> C; C c; C::iterator i; @@ -29,4 +32,16 @@ int main() C::const_iterator j; j = c.cbegin(); assert(i == j); + } +#if __cplusplus >= 201103L + { + typedef std::deque<int, min_allocator<int>> C; + C c; + C::iterator i; + i = c.begin(); + C::const_iterator j; + j = c.cbegin(); + assert(i == j); + } +#endif } diff --git a/libcxx/test/containers/sequences/deque/types.pass.cpp b/libcxx/test/containers/sequences/deque/types.pass.cpp index b9958c94772..9e70299787f 100644 --- a/libcxx/test/containers/sequences/deque/types.pass.cpp +++ b/libcxx/test/containers/sequences/deque/types.pass.cpp @@ -35,6 +35,7 @@ #include "../../test_allocator.h" #include "../../Copyable.h" +#include "../../min_allocator.h" template <class T, class Allocator> void @@ -72,4 +73,17 @@ int main() test<Copyable, test_allocator<Copyable> >(); static_assert((std::is_same<std::deque<char>::allocator_type, std::allocator<char> >::value), ""); +#if __cplusplus >= 201103L + { + typedef std::deque<short, min_allocator<short>> C; + static_assert((std::is_same<C::value_type, short>::value), ""); + static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), ""); + static_assert((std::is_same<C::reference, C::value_type&>::value), ""); + static_assert((std::is_same<C::const_reference, const C::value_type&>::value), ""); + static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), ""); + static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), ""); + static_assert((std::is_same<C::size_type, std::size_t>::value), ""); + static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); + } +#endif } |