diff options
Diffstat (limited to 'libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp')
-rw-r--r-- | libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp | 39 |
1 files changed, 26 insertions, 13 deletions
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 } |