diff options
Diffstat (limited to 'test/std')
740 files changed, 8258 insertions, 8900 deletions
diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp index e24598a9bc12..e2abf7cce42e 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <algorithm> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<RandomAccessIterator Iter> // requires ShuffleIterator<Iter> diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp index c923d847f11e..313b6bac402e 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <algorithm> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand> // requires ShuffleIterator<Iter> diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp index de3f0a741045..1cf2d9e84562 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp @@ -21,6 +21,8 @@ #include "test_iterators.h" +bool equalToTwo(int v) { return v == 2; } + template <class InIter, class OutIter> void test() @@ -28,8 +30,8 @@ test() int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[sa]; - OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib), - std::bind2nd(std::equal_to<int>(), 2)); + OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), + OutIter(ib), equalToTwo); assert(base(r) == ib + sa-3); assert(ib[0] == 0); assert(ib[1] == 1); diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp index 1eff3d39e20e..f2ffece12e8b 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp @@ -23,6 +23,8 @@ #include "test_iterators.h" +bool equalToTwo(int v) { return v == 2; } + template <class InIter, class OutIter> void test() @@ -30,8 +32,8 @@ test() int ia[] = {0, 1, 2, 3, 4}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[sa] = {0}; - OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib), - std::bind2nd(std::equal_to<int>(), 2), 5); + OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), + OutIter(ib), equalToTwo, 5); assert(base(r) == ib + sa); assert(ib[0] == 0); assert(ib[1] == 1); diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp index 8d6ab04e14dd..ebb2945d7c43 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp @@ -22,13 +22,15 @@ #include "test_iterators.h" +bool equalToTwo(int v) { return v == 2; } + template <class Iter> void test() { int ia[] = {0, 1, 2, 3, 4}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); - std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5); + std::replace_if(Iter(ia), Iter(ia+sa), equalToTwo, 5); assert(ia[0] == 0); assert(ia[1] == 1); assert(ia[2] == 5); diff --git a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp index 68556fd98817..6c5e621e4b20 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp @@ -21,6 +21,8 @@ #include "test_iterators.h" +int plusOne(int v) { return v + 1; } + template <class InIter, class OutIter> void test() @@ -28,8 +30,8 @@ test() int ia[] = {0, 1, 2, 3, 4}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[sa] = {0}; - OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib), - std::bind2nd(std::plus<int>(), 1)); + OutIter r = std::transform(InIter(ia), InIter(ia+sa), + OutIter(ib), plusOne); assert(base(r) == ib + sa); assert(ib[0] == 1); assert(ib[1] == 2); diff --git a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp index 025bc06a618d..0a05c6f659ca 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp @@ -20,17 +20,24 @@ #include "test_iterators.h" +struct eq { + eq (int val) : v(val) {} + bool operator () (int v2) const { return v == v2; } + int v; + }; + + int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia + sa), - std::bind2nd(std::equal_to<int>(),2)) == 3); + eq(2)) == 3); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia + sa), - std::bind2nd(std::equal_to<int>(),7)) == 0); + eq(7)) == 0); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia), - std::bind2nd(std::equal_to<int>(),2)) == 0); + eq(2)) == 0); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp index bde6ff389d0c..c942d2e38a58 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp @@ -20,16 +20,22 @@ #include "test_iterators.h" +struct eq { + eq (int val) : v(val) {} + bool operator () (int v2) const { return v == v2; } + int v; + }; + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::equal_to<int>(), 3)); + eq(3)); assert(*r == 3); r = std::find_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::equal_to<int>(), 10)); + eq(10)); assert(r == input_iterator<const int*>(ia+s)); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp index 661e643f07d1..e68344b4b259 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp @@ -20,16 +20,23 @@ #include "test_iterators.h" +struct ne { + ne (int val) : v(val) {} + bool operator () (int v2) const { return v != v2; } + int v; + }; + + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::not_equal_to<int>(), 3)); + ne(3)); assert(*r == 3); r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::not_equal_to<int>(), 10)); + ne(10)); assert(r == input_iterator<const int*>(ia+s)); } diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp index 9da9356b0be1..082cad5f2d08 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp @@ -15,14 +15,17 @@ // make_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); assert(std::is_heap(ia, ia+N)); delete [] ia; diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp index 9d0545f0d9c5..01183d16c927 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <functional> #include <memory> +#include <random> #include <cassert> #include "test_macros.h" @@ -29,6 +30,7 @@ struct indirect_less {return *x < *y;} }; +std::mt19937 randomness; void test(int N) { @@ -36,7 +38,7 @@ void test(int N) { for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); assert(std::is_heap(ia, ia+N, std::greater<int>())); } @@ -64,7 +66,7 @@ void test(int N) // Random { binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>())); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::ref(pred)); assert(pred.count() <= 3u*N); assert(std::is_heap(ia, ia+N, pred)); @@ -90,7 +92,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, indirect_less()); assert(std::is_heap(ia, ia+N, indirect_less())); delete [] ia; diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp index 252fc758cb1f..8ba0f7194062 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp @@ -15,14 +15,17 @@ // pop_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); for (int i = N; i > 0; --i) { diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp index 0bfad61961ed..8e7931f7ea5d 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp @@ -16,10 +16,12 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> + struct indirect_less { template <class P> @@ -29,12 +31,14 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); for (int i = N; i > 0; --i) { @@ -55,7 +59,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, indirect_less()); for (int i = N; i > 0; --i) { diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp index d82896d6a916..38d7a425d82b 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp @@ -16,14 +16,17 @@ // push_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); for (int i = 0; i <= N; ++i) { std::push_heap(ia, ia+i); diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp index 5d2985cc07fa..38d09ceda6e2 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -30,12 +31,14 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); for (int i = 0; i <= N; ++i) { std::push_heap(ia, ia+i, std::greater<int>()); @@ -54,7 +57,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); for (int i = 0; i <= N; ++i) { std::push_heap(ia, ia+i, indirect_less()); diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp index c6eaa8ccec86..003138099f5a 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp @@ -15,14 +15,17 @@ // sort_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); std::sort_heap(ia, ia+N); assert(std::is_sorted(ia, ia+N)); diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp index 1c072c5a12ca..c0a05e4209b3 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp @@ -16,6 +16,7 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -29,12 +30,14 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); std::sort_heap(ia, ia+N, std::greater<int>()); assert(std::is_sorted(ia, ia+N, std::greater<int>())); @@ -56,7 +59,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, indirect_less()); std::sort_heap(ia, ia+N, indirect_less()); assert(std::is_sorted(ia, ia+N, indirect_less())); diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp index 33a42a2f62a1..683b07d32089 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp @@ -16,6 +16,7 @@ // inplace_merge(Iter first, Iter middle, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" @@ -42,6 +43,8 @@ struct S { }; #endif +std::mt19937 randomness; + template <class Iter> void test_one(unsigned N, unsigned M) @@ -51,7 +54,7 @@ test_one(unsigned N, unsigned M) value_type* ia = new value_type[N]; for (unsigned i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::sort(ia, ia+M); std::sort(ia+M, ia+N); std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N)); diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp index fd9e5f13c26a..3d8902ec2271 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" @@ -58,6 +59,8 @@ struct S { #include "test_iterators.h" #include "counting_predicates.hpp" +std::mt19937 randomness; + template <class Iter> void test_one(unsigned N, unsigned M) @@ -67,7 +70,7 @@ test_one(unsigned N, unsigned M) value_type* ia = new value_type[N]; for (unsigned i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::sort(ia, ia+M, std::greater<value_type>()); std::sort(ia+M, ia+N, std::greater<value_type>()); binary_counting_predicate<std::greater<value_type>, value_type, value_type> pred((std::greater<value_type>())); @@ -130,7 +133,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int>[N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::sort(ia, ia+M, indirect_less()); std::sort(ia+M, ia+N, indirect_less()); std::inplace_merge(ia, ia+M, ia+N, indirect_less()); diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp index 2a20cac0b79b..777461023e7d 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp @@ -19,10 +19,13 @@ // merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class InIter1, class InIter2, class OutIter> void test() @@ -53,7 +56,7 @@ test() int* ic = new int[2*N]; for (unsigned i = 0; i < 2*N; ++i) ic[i] = i; - std::random_shuffle(ic, ic+2*N); + std::shuffle(ic, ic+2*N, randomness); std::copy(ic, ic+N, ia); std::copy(ic+N, ic+2*N, ib); std::sort(ia, ia+N); diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp index 152c552381b9..3daaeebbeae9 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp @@ -22,11 +22,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_iterators.h" #include "counting_predicates.hpp" +std::mt19937 randomness; + template <class InIter1, class InIter2, class OutIter> void test() @@ -61,7 +64,7 @@ test() int* ic = new int[2*N]; for (unsigned i = 0; i < 2*N; ++i) ic[i] = i; - std::random_shuffle(ic, ic+2*N); + std::shuffle(ic, ic+2*N, randomness); std::copy(ic, ic+N, ia); std::copy(ic+N, ic+2*N, ib); std::sort(ia, ia+N, std::greater<int>()); diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp index e9cd086ab13d..471b08cc6e1f 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp @@ -15,10 +15,13 @@ // max_element(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -40,7 +43,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp index e60e156455f3..95c7dee2cdb7 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp @@ -16,11 +16,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -42,7 +45,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp index c41884220857..7cd41eaeae46 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp @@ -15,10 +15,13 @@ // min_element(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -40,7 +43,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp index c4c6e31eb6dd..402d57dae69e 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp @@ -16,11 +16,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -42,7 +45,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp index c2805a656137..acede6ff7b56 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp @@ -15,10 +15,13 @@ // minmax_element(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -46,7 +49,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } @@ -66,7 +69,7 @@ test() int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 5; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N)); assert(base(p.first) == a); assert(base(p.second) == a+N-1); diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp index 7840638f742c..ff83d7e55d3d 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp @@ -16,11 +16,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -50,7 +53,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } @@ -70,7 +73,7 @@ test() int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 5; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); typedef std::greater<int> Compare; Compare comp; std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp); diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp index 560bc902b482..b43d88fe0cc6 100644 --- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp @@ -16,8 +16,11 @@ // nth_element(Iter first, Iter nth, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test_one(int N, int M) { @@ -26,7 +29,7 @@ test_one(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::nth_element(array, array+M, array+N); assert(array[M] == M); std::nth_element(array, array+N, array+N); // begin, end, end diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp index f2c962724f09..88249ed78d27 100644 --- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <functional> #include <vector> +#include <random> #include <cassert> #include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -32,6 +33,8 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test_one(int N, int M) { @@ -40,7 +43,7 @@ test_one(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::nth_element(array, array+M, array+N, std::greater<int>()); assert(array[M] == N-M-1); std::nth_element(array, array+N, array+N, std::greater<int>()); // begin, end, end diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp index 1d4ca9925a86..d0b41cca3ca6 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp @@ -18,10 +18,13 @@ // partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test_larger_sorts(int N, int M) @@ -30,7 +33,7 @@ test_larger_sorts(int N, int M) int* output = new int[M]; for (int i = 0; i < N; ++i) input[i] = i; - std::random_shuffle(input, input+N); + std::shuffle(input, input+N, randomness); int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M); int* e = output + std::min(N, M); assert(r == e); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp index 460ea4c08275..0ac2a86afce6 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp @@ -21,10 +21,13 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test_larger_sorts(int N, int M) @@ -33,7 +36,7 @@ test_larger_sorts(int N, int M) int* output = new int[M]; for (int i = 0; i < N; ++i) input[i] = i; - std::random_shuffle(input, input+N); + std::shuffle(input, input+N, randomness); int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M, std::greater<int>()); int* e = output + std::min(N, M); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp index 0d32ba898b8f..05a06a9c3357 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp @@ -16,8 +16,11 @@ // partial_sort(Iter first, Iter middle, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test_larger_sorts(int N, int M) { @@ -26,7 +29,7 @@ test_larger_sorts(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::partial_sort(array, array+M, array+N); for (int i = 0; i < M; ++i) { diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp index a4fe1cc5e7ca..847a5829140a 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <vector> #include <functional> +#include <random> #include <cassert> #include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -32,6 +33,8 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test_larger_sorts(int N, int M) { @@ -40,7 +43,7 @@ test_larger_sorts(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::partial_sort(array, array+M, array+N, std::greater<int>()); for (int i = 0; i < M; ++i) { diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp index 689433f9e45b..6149a574b230 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp @@ -17,8 +17,11 @@ #include <algorithm> #include <iterator> +#include <random> #include <cassert> +std::mt19937 randomness; + template <class RI> void test_sort_helper(RI f, RI l) @@ -92,7 +95,7 @@ test_larger_sorts(int N, int M) std::sort(array, array+N); assert(std::is_sorted(array, array+N)); // test random pattern - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::sort(array, array+N); assert(std::is_sorted(array, array+N)); // test sorted pattern diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp index 336fcd0b3dde..994d3a8c4a7c 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp @@ -17,8 +17,11 @@ #include <algorithm> #include <iterator> +#include <random> #include <cassert> +std::mt19937 randomness; + template <class RI> void test_sort_helper(RI f, RI l) @@ -92,7 +95,7 @@ test_larger_sorts(int N, int M) std::stable_sort(array, array+N); assert(std::is_sorted(array, array+N)); // test random pattern - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::stable_sort(array, array+N); assert(std::is_sorted(array, array+N)); // test sorted pattern diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp index 49f7122cdb31..347711bf5e3a 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <functional> #include <vector> +#include <random> #include <cassert> #include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -32,6 +33,8 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + struct first_only { bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y) @@ -59,7 +62,7 @@ void test() } for (int i = 0; i < N - M; i += M) { - std::random_shuffle(v.begin() + i, v.begin() + i + M); + std::shuffle(v.begin() + i, v.begin() + i + M, randomness); } std::stable_sort(v.begin(), v.end(), first_only()); assert(std::is_sorted(v.begin(), v.end())); diff --git a/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp b/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp index 32d34d90d7f8..646c6be7da61 100644 --- a/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp +++ b/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp @@ -13,7 +13,7 @@ // <map> // Previously this code caused a segfault when compiled at -O2 due to undefined -// behavior in __tree. See https://llvm.org/bugs/show_bug.cgi?id=28469 +// behavior in __tree. See https://bugs.llvm.org/show_bug.cgi?id=28469 #include <functional> #include <map> diff --git a/test/std/containers/associative/map/compare.pass.cpp b/test/std/containers/associative/map/compare.pass.cpp index 9d1c13d7b8e6..8c429cbd3c4b 100644 --- a/test/std/containers/associative/map/compare.pass.cpp +++ b/test/std/containers/associative/map/compare.pass.cpp @@ -13,8 +13,8 @@ // class Allocator = allocator<pair<const Key, T>>> // class map -// http://llvm.org/bugs/show_bug.cgi?id=16538 -// http://llvm.org/bugs/show_bug.cgi?id=16549 +// https://bugs.llvm.org/show_bug.cgi?id=16538 +// https://bugs.llvm.org/show_bug.cgi?id=16549 #include <map> #include <utility> diff --git a/test/std/containers/associative/map/incomplete_type.pass.cpp b/test/std/containers/associative/map/incomplete_type.pass.cpp index 84c2451ce087..6acf83129e12 100644 --- a/test/std/containers/associative/map/incomplete_type.pass.cpp +++ b/test/std/containers/associative/map/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <map> -// Check that std::map and it's iterators can be instantiated with an incomplete +// Check that std::map and its iterators can be instantiated with an incomplete // type. #include <map> diff --git a/test/std/containers/associative/map/map.access/index_tuple.pass.cpp b/test/std/containers/associative/map/map.access/index_tuple.pass.cpp index 9a00829eadd6..f8fc21f1f2f5 100644 --- a/test/std/containers/associative/map/map.access/index_tuple.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_tuple.pass.cpp @@ -13,7 +13,7 @@ // mapped_type& operator[](const key_type& k); -// http://llvm.org/bugs/show_bug.cgi?id=16542 +// https://bugs.llvm.org/show_bug.cgi?id=16542 #include <map> diff --git a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp index 817f1207ac94..e06410dcffa2 100644 --- a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -37,14 +37,16 @@ struct some_comp int main() { typedef std::pair<const MoveOnly, MoveOnly> V; +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index a0cf689ed909..7f563b7cf635 100644 --- a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -43,8 +43,10 @@ int main() typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index 705fb580487b..923a2124ece4 100644 --- a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -92,7 +92,6 @@ int main() V(3, 2), }; { - typedef std::pair<const int, double> V; typedef min_allocator<V> A; typedef test_compare<std::less<int> > C; A a; @@ -106,7 +105,6 @@ int main() assert(m.get_allocator() == a); } { - typedef std::pair<const int, double> V; typedef explicit_allocator<V> A; typedef test_compare<std::less<int> > C; A a; diff --git a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp index 84f115f1958e..b45e821ad0f9 100644 --- a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -45,10 +45,12 @@ int main() typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp index b5301418e85a..84a9609742d3 100644 --- a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -34,19 +34,21 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index 84907945a90e..c1aa033845ec 100644 --- a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -99,14 +99,16 @@ int main() typedef std::map<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -129,11 +131,12 @@ int main() typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/associative/multimap/incomplete_type.pass.cpp b/test/std/containers/associative/multimap/incomplete_type.pass.cpp index c461eb38139d..306f3d9761f1 100644 --- a/test/std/containers/associative/multimap/incomplete_type.pass.cpp +++ b/test/std/containers/associative/multimap/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <map> -// Check that std::multimap and it's iterators can be instantiated with an incomplete +// Check that std::multimap and its iterators can be instantiated with an incomplete // type. #include <map> diff --git a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp index 6f97a5f3e756..6020334ed26b 100644 --- a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -37,14 +37,16 @@ struct some_comp int main() { typedef std::pair<const MoveOnly, MoveOnly> V; +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp index 669d23db57cd..2486e8f243cf 100644 --- a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -43,8 +43,10 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp index 7637885c81e1..549c1210b6f2 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -45,10 +45,12 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp index e42251527eb3..fdcdffbedb4b 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -34,19 +34,21 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp index df46d376e028..9e67f97f9ac0 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp @@ -183,7 +183,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef std::pair<M::iterator, M::iterator> R; diff --git a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp index f5295e52d192..474b7b6ac59c 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp @@ -147,7 +147,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp index 8a650fa55975..28ff332542b4 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp @@ -155,7 +155,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef M::iterator R; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp index 05760dc0e751..4f4b3884f28e 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp @@ -155,7 +155,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef M::iterator R; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index ecc9c7ef5fd4..8148ea5b27ed 100644 --- a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -99,14 +99,16 @@ int main() typedef std::multimap<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -129,10 +131,11 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/associative/multiset/incomplete_type.pass.cpp b/test/std/containers/associative/multiset/incomplete_type.pass.cpp index 0355e18f9f29..aecd77a18367 100644 --- a/test/std/containers/associative/multiset/incomplete_type.pass.cpp +++ b/test/std/containers/associative/multiset/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <set> -// Check that std::multiset and it's iterators can be instantiated with an incomplete +// Check that std::multiset and its iterators can be instantiated with an incomplete // type. #include <set> diff --git a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp index 15520e7834ff..3156003232db 100644 --- a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp @@ -36,14 +36,16 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp index b4b9d067704b..096696fcd94c 100644 --- a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp index bae97cf4e48a..18d64bc5f2c8 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp @@ -44,10 +44,12 @@ int main() typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp index 69759e03a28a..eab1787ec881 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp @@ -34,18 +34,20 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp index 89fabef0a3a0..9693ffb15903 100644 --- a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp @@ -98,14 +98,16 @@ int main() typedef std::multiset<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -128,10 +130,11 @@ int main() typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/associative/set/incomplete_type.pass.cpp b/test/std/containers/associative/set/incomplete_type.pass.cpp index d3a1d6638d7e..a200223051c8 100644 --- a/test/std/containers/associative/set/incomplete_type.pass.cpp +++ b/test/std/containers/associative/set/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <set> -// Check that std::set and it's iterators can be instantiated with an incomplete +// Check that std::set and its iterators can be instantiated with an incomplete // type. #include <set> diff --git a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp index 6293c24a43d3..d32cc3f48fef 100644 --- a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp @@ -36,14 +36,16 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp index 041f599c1f76..c91038e39040 100644 --- a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp index ce44b69fe336..c07d4e6f9b88 100644 --- a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp @@ -44,10 +44,12 @@ int main() typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp index 9a7538ca31bd..901fdbdb321c 100644 --- a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp @@ -34,18 +34,20 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp index b3edd31f749b..38b0ab8151aa 100644 --- a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp @@ -98,14 +98,16 @@ int main() typedef std::set<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -128,11 +130,12 @@ int main() typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp index c79feb93eb6c..5dec2b910fb7 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp @@ -25,8 +25,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::priority_queue<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp index 43045893fe07..781d74016128 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::queue<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp index c8becb3ca98a..58c8f9ddfad1 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::queue<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp index 2d1f9437fc45..2e217c545f9c 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::stack<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp index c34b7e07000e..af6793f465a2 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::stack<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/array/array.size/size.pass.cpp b/test/std/containers/sequences/array/array.size/size.pass.cpp index a833fdc04715..2fe5355124ae 100644 --- a/test/std/containers/sequences/array/array.size/size.pass.cpp +++ b/test/std/containers/sequences/array/array.size/size.pass.cpp @@ -14,6 +14,8 @@ #include <array> #include <cassert> +#include "test_macros.h" + // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" @@ -36,7 +38,7 @@ int main() assert(c.max_size() == 0); assert(c.empty()); } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { typedef double T; typedef std::array<T, 3> C; diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp index 8e7ff6dff702..efec4e403001 100644 --- a/test/std/containers/sequences/array/at.pass.cpp +++ b/test/std/containers/sequences/array/at.pass.cpp @@ -25,7 +25,7 @@ #if TEST_STD_VER > 14 constexpr bool check_idx( size_t idx, double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr.at(idx) == val; } diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp index 239fda5c99d8..68fc6cdc4543 100644 --- a/test/std/containers/sequences/array/front_back.pass.cpp +++ b/test/std/containers/sequences/array/front_back.pass.cpp @@ -25,13 +25,13 @@ #if TEST_STD_VER > 14 constexpr bool check_front( double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr.front() == val; } constexpr bool check_back( double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr.back() == val; } diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp index 6cb7941d92c5..3a5b9ee9727d 100644 --- a/test/std/containers/sequences/array/indexing.pass.cpp +++ b/test/std/containers/sequences/array/indexing.pass.cpp @@ -25,7 +25,7 @@ #if TEST_STD_VER > 14 constexpr bool check_idx( size_t idx, double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr[idx] == val; } diff --git a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp index dea6492a515d..fdb751da6aaf 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d; d.assign({3, 4, 5, 6}); @@ -28,7 +29,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d; d.assign({3, 4, 5, 6}); @@ -38,6 +38,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp index 30cca929da11..e79e6eca3d95 100644 --- a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp @@ -32,14 +32,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp index 59955157421d..288810089e59 100644 --- a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp index dbf27053a9f9..dd70cda1845b 100644 --- a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -27,7 +28,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -36,6 +36,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp index 9be3c63a6b31..2619569e154e 100644 --- a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ 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)); @@ -29,7 +30,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); @@ -39,6 +39,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp index 68875139da1a..6e935a52bb24 100644 --- a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(deque&&); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { 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]); @@ -51,7 +52,6 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == c1.get_allocator()); } -#if TEST_STD_VER >= 11 { 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]); @@ -67,6 +67,4 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == c1.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp index 4aa0fa6827e7..5a9a77c746fc 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(deque&& c, const allocator_type& a); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { 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]); @@ -66,7 +67,6 @@ int main() assert(c3.get_allocator() == A(3)); assert(c1.size() != 0); } -#if TEST_STD_VER >= 11 { 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]); @@ -82,6 +82,4 @@ int main() assert(c3.get_allocator() == A()); assert(c1.size() == 0); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp index ed8f1544bc8f..8a65bc2d2e84 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque& operator=(deque&& c); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { 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]); @@ -69,7 +70,6 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == A(5)); } -#if TEST_STD_VER >= 11 { 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]); @@ -86,6 +86,4 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp index 9b813ce342a3..6ea72246fa05 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp @@ -42,12 +42,14 @@ int main() typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp index e0669dc70ca9..fdf67d23a12d 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp @@ -32,18 +32,20 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp index 597f642db3ce..117e942895ba 100644 --- a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque& operator=(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d; d = {3, 4, 5, 6}; @@ -28,7 +29,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d; d = {3, 4, 5, 6}; @@ -38,6 +38,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp index 64b3d811fdc9..de7894234df3 100644 --- a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp @@ -68,7 +68,6 @@ test3(unsigned n, Allocator const &alloc = Allocator()) { #if TEST_STD_VER > 11 typedef std::deque<T, Allocator> C; - typedef typename C::const_iterator const_iterator; { C d(n, alloc); assert(d.size() == n); diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp index 5f7804023c7f..6d33424fe410 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ 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}); @@ -59,5 +60,4 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp index b5c881064a95..060d83b5e254 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void push_back(value_type&& v); @@ -19,7 +21,6 @@ #include "MoveOnly.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class C> C @@ -57,24 +58,19 @@ void test(int size) } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 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<std::deque<MoveOnly> >(rng[j]); } -#if TEST_STD_VER >= 11 { 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/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp index 8e734a639344..df3d2d099c70 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void push_front(value_type&& v); @@ -18,7 +20,6 @@ #include "MoveOnly.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class C> C @@ -66,11 +67,9 @@ testN(int start, int N) test(c1, -10); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 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]); @@ -78,7 +77,6 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<MoveOnly> >(rng[i], rng[j]); } -#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -86,6 +84,4 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp index c0af762fb277..0db30a031282 100644 --- a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp @@ -59,14 +59,16 @@ int main() typedef std::deque<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp index d4dda02b8413..69fb6eb4ca4d 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // void assign(initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -42,7 +43,6 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -65,6 +65,4 @@ int main() assert(*i == 10+n); assert(n == 4); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp index 935284831d07..61118353dfb2 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list& operator=(forward_list&& x); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef test_allocator<T> A; @@ -159,7 +160,6 @@ int main() assert(c1.get_allocator() == A(10)); assert(c0.empty()); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; @@ -194,6 +194,4 @@ int main() assert(c1.get_allocator() == A()); assert(c0.empty()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp index 3d35916ccacb..84f1eb9963fd 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list& operator=(initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -42,7 +43,6 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -65,6 +65,4 @@ int main() assert(*i == 10+n); assert(n == 4); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp index 0ec1f80562a8..57f09d7cefeb 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp @@ -32,14 +32,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp index f70119e3c2af..4d295d662da1 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp index ac73d142a67e..7575c0e81242 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -28,7 +29,6 @@ int main() assert(*i == n); assert(n == 10); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -38,6 +38,4 @@ int main() assert(*i == n); assert(n == 10); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp index 844be20015dd..cf9cbffa7304 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(initializer_list<value_type> il, const allocator_type& a); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef test_allocator<T> A; @@ -31,7 +32,6 @@ int main() assert(n == 10); assert(c.get_allocator() == A(14)); } -#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<T> A; @@ -43,6 +43,4 @@ int main() assert(n == 10); assert(c.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index a5948b9ef799..92a9e39fc94b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(forward_list&& x); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef test_allocator<T> A; @@ -52,7 +53,6 @@ int main() assert(c0.empty()); assert(c.get_allocator() == A(10)); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; @@ -68,6 +68,4 @@ int main() assert(c0.empty()); assert(c.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp index 6a1afe1334b0..5f5f5d0aef60 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(forward_list&& x, const allocator_type& a); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef test_allocator<T> A; @@ -33,7 +34,7 @@ int main() unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); - assert(n == std::end(t) - std::begin(t)); + assert(n == static_cast<unsigned>(std::end(t) - std::begin(t))); assert(c0.empty()); assert(c.get_allocator() == A(10)); } @@ -48,11 +49,10 @@ int main() unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); - assert(n == std::end(t) - std::begin(t)); + assert(n == static_cast<unsigned>(std::end(t) - std::begin(t))); assert(!c0.empty()); assert(c.get_allocator() == A(9)); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; @@ -64,10 +64,8 @@ int main() unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); - assert(n == std::end(t) - std::begin(t)); + assert(n == static_cast<unsigned>(std::end(t) - std::begin(t))); assert(c0.empty()); assert(c.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp index 5f278e31c0de..d4fe2591898a 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp @@ -42,12 +42,14 @@ int main() typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp index 089f6d6807cb..3390c331e00e 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp @@ -32,18 +32,20 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp deleted file mode 100644 index 2d963a1be479..000000000000 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <forward_list> - -// explicit forward_list(size_type n); - -#include <forward_list> -#include <cassert> - -#include "DefaultOnly.h" - -int main() -{ - { - typedef DefaultOnly T; - typedef std::forward_list<T> C; - unsigned N = 10; - C c = N; - unsigned n = 0; - for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(*i == T()); -#else - ; -#endif - assert(n == N); - } -} diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp index b536ccf4910e..061dd6da0785 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp @@ -36,6 +36,11 @@ void check_allocator(unsigned n, Allocator const &alloc = Allocator()) int main() { + { // test that the ctor is explicit + typedef std::forward_list<DefaultOnly> C; + static_assert((std::is_constructible<C, size_t>::value), ""); + static_assert((!std::is_convertible<size_t, C>::value), ""); + } { typedef DefaultOnly T; typedef std::forward_list<T> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp index dd8ea88c2c1a..8d7c4e9893a2 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // template <class... Args> @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef Emplaceable T; typedef std::forward_list<T> C; @@ -52,7 +53,6 @@ int main() assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); assert(distance(c.begin(), c.end()) == 4); } -#if TEST_STD_VER >= 11 { typedef Emplaceable T; typedef std::forward_list<T, min_allocator<T>> C; @@ -84,6 +84,4 @@ int main() assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); assert(distance(c.begin(), c.end()) == 4); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp index 15e1a08b08bf..90ee0d2313ff 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // iterator insert_after(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -44,7 +45,6 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -70,6 +70,4 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp index 2e21cc79d269..173ccaa62d9f 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // iterator insert_after(const_iterator p, value_type&& v); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef std::forward_list<T> C; @@ -52,7 +53,6 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; @@ -85,6 +85,4 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp index d831ceb28918..545b0e68a24b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp @@ -32,7 +32,7 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T> C; @@ -45,8 +45,6 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -60,7 +58,6 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; @@ -73,6 +70,5 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp index dfcd2cf90ebc..7fc2b9d76567 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // void push_front(value_type&& v); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef std::forward_list<T> C; @@ -32,7 +33,6 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; @@ -45,6 +45,4 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp index 65512e317cea..397f209f7226 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp @@ -15,10 +15,13 @@ #include <iterator> #include <algorithm> #include <vector> +#include <random> #include <cassert> #include "min_allocator.h" +std::mt19937 randomness; + template <class C> void test(int N) { @@ -27,7 +30,7 @@ void test(int N) V v; for (int i = 0; i < N; ++i) v.push_back(i); - std::random_shuffle(v.begin(), v.end()); + std::shuffle(v.begin(), v.end(), randomness); C c(v.begin(), v.end()); c.sort(); assert(distance(c.begin(), c.end()) == N); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp index 6e5cce39e67d..ab6ae6bd327b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp @@ -16,10 +16,13 @@ #include <algorithm> #include <vector> #include <functional> +#include <random> #include <cassert> #include "min_allocator.h" +std::mt19937 randomness; + template <class C> void test(int N) { @@ -28,7 +31,7 @@ void test(int N) V v; for (int i = 0; i < N; ++i) v.push_back(i); - std::random_shuffle(v.begin(), v.end()); + std::shuffle(v.begin(), v.end(), randomness); C c(v.begin(), v.end()); c.sort(std::greater<T>()); assert(distance(c.begin(), c.end()) == N); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp index c63194f7ee64..d93c079e15ed 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -59,14 +59,16 @@ int main() typedef std::forward_list<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/containers/sequences/list/incomplete_type.pass.cpp b/test/std/containers/sequences/list/incomplete_type.pass.cpp index adfb4d45fc81..aff8f0367893 100644 --- a/test/std/containers/sequences/list/incomplete_type.pass.cpp +++ b/test/std/containers/sequences/list/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <list> -// Check that std::list and it's iterators can be instantiated with an incomplete +// Check that std::list and its iterators can be instantiated with an incomplete // type. #include <list> diff --git a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp index 9b2c6d68cbe5..4704cf40aafa 100644 --- a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d; d.assign({3, 4, 5, 6}); @@ -29,7 +30,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d; d.assign({3, 4, 5, 6}); @@ -40,6 +40,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp index 2f863c6169fc..eec214205178 100644 --- a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list& operator=(list&& c); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -62,7 +63,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -77,6 +77,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp index 6f76d8c56882..7f3114d6e1c4 100644 --- a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp @@ -32,14 +32,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp index 66e40a30d1f1..b5ec50637ab8 100644 --- a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp index 40413203bdfc..8f04e7342fc6 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -28,7 +29,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -38,6 +38,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp index 6040c648e547..3388e00dfb03 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); @@ -30,7 +31,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); @@ -41,6 +41,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp index 9f8a536b33c5..7236f7cc6ac2 100644 --- a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(list&& c, const allocator_type& a); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -59,7 +60,6 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -73,6 +73,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == min_allocator<MoveOnly>()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp index 81f78116af2e..0d3ccfa68c93 100644 --- a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp @@ -42,12 +42,14 @@ int main() typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp index b40cb718a3f1..878dab66f0ad 100644 --- a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp @@ -32,18 +32,20 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp index 1097bdab2198..b638e219d9c8 100644 --- a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list& operator=(initializer_list<value_type> il); @@ -17,7 +19,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d; d = {3, 4, 5, 6}; @@ -28,7 +29,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d; d = {3, 4, 5, 6}; @@ -39,6 +39,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp index 95cdeb0c8539..cbe790c0f3bc 100644 --- a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp @@ -25,7 +25,6 @@ test3(unsigned n, Allocator const &alloc = Allocator()) { #if TEST_STD_VER > 11 typedef std::list<T, Allocator> C; - typedef typename C::const_iterator const_iterator; { C d(n, alloc); assert(d.size() == n); diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp index 91845e564b02..2d5231e78209 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d(10, 1); std::list<int>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6}); @@ -40,7 +41,6 @@ int main() assert(*i++ == 1); assert(*i++ == 1); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d(10, 1); std::list<int, min_allocator<int>>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6}); @@ -62,6 +62,4 @@ int main() assert(*i++ == 1); assert(*i++ == 1); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp index 10acede511f4..3d9d00abe52f 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void push_back(value_type&& x); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly> l1; l1.push_back(MoveOnly(1)); @@ -30,7 +31,6 @@ int main() assert(l1.front() == MoveOnly(1)); assert(l1.back() == MoveOnly(2)); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.push_back(MoveOnly(1)); @@ -41,6 +41,4 @@ int main() assert(l1.front() == MoveOnly(1)); assert(l1.back() == MoveOnly(2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp index 5321ee0faed3..6fef6ade9c79 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void push_front(value_type&& x); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly> l1; l1.push_front(MoveOnly(1)); @@ -30,7 +31,6 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.push_front(MoveOnly(1)); @@ -41,6 +41,4 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp index 512635359c5d..cfe1bfd2f411 100644 --- a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp @@ -59,14 +59,16 @@ int main() typedef std::list<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp index ac7a2ce38adf..60146a88b3b5 100644 --- a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d; d.assign({true, false, false, true}); @@ -28,7 +29,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d.assign({true, false, false, true}); @@ -38,6 +38,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp index f07c1d90059d..13cd65f33123 100644 --- a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(vector&& c); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -61,7 +62,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -76,6 +76,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp index 4f860dabac95..4e71df37421e 100644 --- a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp @@ -31,14 +31,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<bool, other_allocator<bool>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp index b8ff33c5d2e8..5f1f5d10485d 100644 --- a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp @@ -41,8 +41,10 @@ int main() typedef std::vector<bool, other_allocator<bool>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, some_alloc<bool>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/test/std/containers/sequences/vector.bool/emplace.pass.cpp index ccdce913c73c..8a1ed033488a 100644 --- a/test/std/containers/sequences/vector.bool/emplace.pass.cpp +++ b/test/std/containers/sequences/vector.bool/emplace.pass.cpp @@ -34,7 +34,7 @@ int main() assert(c.front() == false); assert(c.back() == true); - i = c.emplace(c.cbegin()+1, 1 == 1); + i = c.emplace(c.cbegin()+1, true); assert(i == c.begin()+1); assert(c.size() == 3); assert(c.front() == false); @@ -56,7 +56,7 @@ int main() assert(c.front() == false); assert(c.back() == true); - i = c.emplace(c.cbegin()+1, 1 == 1); + i = c.emplace(c.cbegin()+1, true); assert(i == c.begin()+1); assert(c.size() == 3); assert(c.size() == 3); diff --git a/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp b/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp new file mode 100644 index 000000000000..f8a8dbd8d6d4 --- /dev/null +++ b/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <vector> + +// Test that <vector> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <vector> + +#include "poisoned_hash_helper.hpp" +#include "min_allocator.h" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::vector<bool> >(); + test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>(); + } +} diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp index ffe844e0079c..d5c3f458c634 100644 --- a/test/std/containers/sequences/vector.bool/find.pass.cpp +++ b/test/std/containers/sequences/vector.bool/find.pass.cpp @@ -12,7 +12,7 @@ // std::find with vector<bool>::iterator -// http://llvm.org/bugs/show_bug.cgi?id=16816 +// https://bugs.llvm.org/show_bug.cgi?id=16816 #include <vector> #include <algorithm> diff --git a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp index 07bae0eb7089..a850fa2f1cdd 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d = {true, false, false, true}; assert(d.size() == 4); @@ -27,7 +28,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d = {true, false, false, true}; assert(d.size() == 4); @@ -36,6 +36,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp index 5f7f5144f841..9a2df4290e77 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3)); assert(d.get_allocator() == test_allocator<bool>(3)); @@ -29,7 +30,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>()); assert(d.get_allocator() == min_allocator<bool>()); @@ -39,6 +39,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp index 3a176d94e860..df4cb199b8fd 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d(10, true); std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); @@ -39,7 +40,6 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d(10, true); std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); @@ -60,6 +60,4 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/move.pass.cpp b/test/std/containers/sequences/vector.bool/move.pass.cpp index f3a11ec562c0..f189e2b97092 100644 --- a/test/std/containers/sequences/vector.bool/move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -45,7 +46,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -59,6 +59,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp index 7aaa7c55550b..b3b6f964966b 100644 --- a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c, const allocator_type& a); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -58,7 +59,6 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<bool>(4)); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -72,6 +72,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == min_allocator<bool>()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp index dd4bf9e01ea9..556b6e656439 100644 --- a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp @@ -59,31 +59,40 @@ struct some_alloc3 int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<bool, test_allocator<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER > 14 - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); +#if defined(_LIBCPP_VERSION) + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( std::is_nothrow_move_assignable<C>::value, ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); #endif } #if TEST_STD_VER > 14 +#if defined(_LIBCPP_VERSION) { // POCMA false, is_always_equal true typedef std::vector<bool, some_alloc2<bool>> C; - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); + static_assert( std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { // POCMA false, is_always_equal false typedef std::vector<bool, some_alloc3<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp index 3305d95e1ab8..f104eb32e5f4 100644 --- a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp @@ -31,24 +31,29 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; // In C++17, move constructors for allocators are not allowed to throw #if TEST_STD_VER > 14 - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_constructible<C>::value, ""); +#if defined(_LIBCPP_VERSION) + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( std::is_nothrow_move_constructible<C>::value, ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); #endif } diff --git a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp index 4b959cf00ad3..61874338d655 100644 --- a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d; d = {true, false, false, true}; @@ -28,7 +29,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d = {true, false, false, true}; @@ -38,6 +38,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp index 1b68eda2757b..d888af05f92f 100644 --- a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -55,32 +55,39 @@ struct some_alloc2 int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER >= 14 +#if defined(_LIBCPP_VERSION) // In c++14, if POCS is set, swapping the allocator is required not to throw - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, some_alloc2<bool>> C; // if the allocators are always equal, then the swap can be noexcept - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp index 4f82792fa1fd..64104a40ec74 100644 --- a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp +++ b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp @@ -31,7 +31,8 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); - + ASSERT_NOEXCEPT(H()(T())); + bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; @@ -43,6 +44,7 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp index 6409acaf65c1..273bdad9acdb 100644 --- a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp @@ -13,6 +13,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "MoveOnly.h" #include "min_allocator.h" @@ -20,9 +22,8 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { - std::vector<MoveOnly> v(100); + std::vector<int> v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -34,7 +35,7 @@ int main() } { // Add 1 for implementations that dynamically allocate a container proxy. - std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100); + std::vector<int, limited_allocator<int, 300 + 1> > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -44,9 +45,9 @@ int main() assert(v.capacity() >= 200); assert(is_contiguous_container_asan_correct(v)); } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { - std::vector<int> v(100); + std::vector<MoveOnly> v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -58,7 +59,7 @@ int main() } { // Add 1 for implementations that dynamically allocate a container proxy. - std::vector<int, limited_allocator<int, 300 + 1> > v(100); + std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -68,8 +69,6 @@ int main() assert(v.capacity() >= 200); assert(is_contiguous_container_asan_correct(v)); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> v(100); v.resize(50); diff --git a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp index 222fa9c78f92..853f75583ddc 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void assign(initializer_list<value_type> il); @@ -20,7 +22,6 @@ template <typename Vec> void test ( Vec &v ) { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS v.assign({3, 4, 5, 6}); assert(v.size() == 4); assert(is_contiguous_container_asan_correct(v)); @@ -28,7 +29,6 @@ void test ( Vec &v ) assert(v[1] == 4); assert(v[2] == 5); assert(v[3] == 6); -#endif } int main() @@ -41,8 +41,6 @@ int main() test(d1); test(d2); } - -#if TEST_STD_VER >= 11 { typedef std::vector<int, min_allocator<int>> V; V d1; @@ -51,5 +49,4 @@ int main() test(d1); test(d2); } -#endif } diff --git a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp index acbee97bcd1c..c2b6b83784f2 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(vector&& c); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -76,7 +77,6 @@ int main() assert(l2.get_allocator() == lo.get_allocator()); assert(is_contiguous_container_asan_correct(l2)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -96,6 +96,4 @@ int main() assert(l2.get_allocator() == lo.get_allocator()); assert(is_contiguous_container_asan_correct(l2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp index 10a381f9c8cc..1720866940ed 100644 --- a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp index 408bcc3b1499..edbad8c0d95b 100644 --- a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -28,7 +29,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -38,6 +38,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp index f4c3b5c1e8e0..ac5d0178e73a 100644 --- a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); @@ -31,7 +32,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); @@ -42,6 +42,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp index d51b364f3ba0..cd50d5432349 100644 --- a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -68,7 +69,6 @@ int main() assert(*j == 3); assert(is_contiguous_container_asan_correct(c2)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -98,6 +98,4 @@ int main() assert(*j == 3); assert(is_contiguous_container_asan_correct(c2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp index fcdd35ae1157..767a0ce3dce9 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c, const allocator_type& a); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -75,7 +76,6 @@ int main() assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); assert(is_contiguous_container_asan_correct(l2)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -94,6 +94,4 @@ int main() assert(l2.get_allocator() == min_allocator<MoveOnly>()); assert(is_contiguous_container_asan_correct(l2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp index 4e5a20413683..21dd5c384b58 100644 --- a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> d; d = {3, 4, 5, 6}; @@ -30,7 +31,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d; d = {3, 4, 5, 6}; @@ -41,6 +41,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp new file mode 100644 index 000000000000..5f053eb8565a --- /dev/null +++ b/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <vector> + +// void clear(); + +#include <vector> +#include <cassert> + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + int a[] = {1, 2, 3}; + std::vector<int> c(a, a+3); + c.clear(); + assert(c.empty()); + LIBCPP_ASSERT(c.__invariants()); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + } +#if TEST_STD_VER >= 11 + { + int a[] = {1, 2, 3}; + std::vector<int, min_allocator<int>> c(a, a+3); + c.clear(); + assert(c.empty()); + LIBCPP_ASSERT(c.__invariants()); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + } +#endif +} diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp index 7e4aed8c1b5e..e5e0277fa37a 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // template <class... Args> iterator emplace(const_iterator pos, Args&&... args); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> v; v.reserve(3); @@ -38,7 +39,6 @@ int main() assert(v[0] == 3); assert(is_contiguous_container_asan_correct(v)); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v; v.reserve(3); @@ -57,6 +57,4 @@ int main() assert(v[0] == 3); assert(is_contiguous_container_asan_correct(v)); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp index b0fe123aac48..9072d427cab7 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> d(10, 1); std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); @@ -41,7 +42,6 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d(10, 1); std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); @@ -63,6 +63,4 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp index f4a1f5d5f519..ac1fffd9d0d7 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void push_back(value_type&& x); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly> c; c.push_back(MoveOnly(0)); @@ -81,7 +82,6 @@ int main() for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j) assert(c[j] == MoveOnly(j)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> c; c.push_back(MoveOnly(0)); @@ -110,6 +110,4 @@ int main() for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j) assert(c[j] == MoveOnly(j)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp index 214f9a577571..f92ab8a5c300 100644 --- a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp @@ -60,10 +60,12 @@ int main() typedef std::vector<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); diff --git a/test/std/containers/unord/unord.map/compare.pass.cpp b/test/std/containers/unord/unord.map/compare.pass.cpp index ea6d02f5fcbc..cffc1dbd42c1 100644 --- a/test/std/containers/unord/unord.map/compare.pass.cpp +++ b/test/std/containers/unord/unord.map/compare.pass.cpp @@ -13,8 +13,8 @@ // class Alloc = allocator<pair<const Key, T>>> // class unordered_map -// http://llvm.org/bugs/show_bug.cgi?id=16538 -// http://llvm.org/bugs/show_bug.cgi?id=16549 +// https://bugs.llvm.org/show_bug.cgi?id=16538 +// https://bugs.llvm.org/show_bug.cgi?id=16549 #include <unordered_map> #include <cassert> diff --git a/test/std/containers/unord/unord.map/incomplete_type.pass.cpp b/test/std/containers/unord/unord.map/incomplete_type.pass.cpp index d51b1d8d181f..9fc0fd471ef5 100644 --- a/test/std/containers/unord/unord.map/incomplete_type.pass.cpp +++ b/test/std/containers/unord/unord.map/incomplete_type.pass.cpp @@ -10,7 +10,7 @@ // <unordered_map> -// Check that std::unordered_map and it's iterators can be instantiated with an incomplete +// Check that std::unordered_map and its iterators can be instantiated with an incomplete // type. #include <unordered_map> diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp index 939e0bcd4e69..7ef7f47ff865 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,23 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp index 4fb10afd4e59..0fe98abe774d 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,8 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +55,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp index c0dc71da45d8..4191102a85ab 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,8 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +56,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp index c40173ede750..2eb8c946720f 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,28 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp index f2c694e86f74..400e0283fef2 100644 --- a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp @@ -17,7 +17,7 @@ // mapped_type& operator[](const key_type& k); -// http://llvm.org/bugs/show_bug.cgi?id=16542 +// https://bugs.llvm.org/show_bug.cgi?id=16542 #include <unordered_map> #include <tuple> diff --git a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp index fc286ceec8eb..75807fa78889 100644 --- a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp @@ -64,6 +64,7 @@ struct some_hash typedef T value_type; some_hash() {} some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; template <class T> @@ -72,6 +73,7 @@ struct some_hash2 typedef T value_type; some_hash2() {} some_hash2(const some_hash2&); + std::size_t operator()(T const&) const; }; #if TEST_STD_VER >= 14 @@ -125,16 +127,18 @@ int main() typedef std::unordered_map<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MapType>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MapType>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -178,10 +182,11 @@ int main() typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MapType>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp index 4eea3d0f6fb5..5cb60f6a6d91 100644 --- a/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp @@ -25,14 +25,11 @@ int main() { { typedef std::unordered_multimap<int, std::string> C; - typedef C::const_iterator I; - typedef std::pair<int, std::string> P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_multimap<int, std::string> C; - typedef C::const_iterator I; typedef std::pair<int, std::string> P; P a[] = { diff --git a/test/std/containers/unord/unord.multimap/incomplete.pass.cpp b/test/std/containers/unord/unord.multimap/incomplete.pass.cpp index 7822224e7366..67bff9419757 100644 --- a/test/std/containers/unord/unord.multimap/incomplete.pass.cpp +++ b/test/std/containers/unord/unord.multimap/incomplete.pass.cpp @@ -10,7 +10,7 @@ // <unordered_map> -// Check that std::unordered_multimap and it's iterators can be instantiated with an incomplete +// Check that std::unordered_multimap and its iterators can be instantiated with an incomplete // type. #include <unordered_map> diff --git a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp index 9c42435946ff..ff3bc0105bd3 100644 --- a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp @@ -44,7 +44,6 @@ int main() } { typedef std::unordered_multimap<int, std::string> C; - typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } @@ -70,7 +69,6 @@ int main() { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp index a2ab399d3469..3e9a10ab798a 100644 --- a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp @@ -25,8 +25,6 @@ int main() { { typedef std::unordered_multimap<int, std::string> C; - typedef C::const_iterator I; - typedef std::pair<int, std::string> P; const C c; assert(c.max_bucket_count() > 0); } @@ -34,8 +32,6 @@ int main() { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef C::const_iterator I; - typedef std::pair<int, std::string> P; const C c; assert(c.max_bucket_count() > 0); } diff --git a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp index b0b2b664f098..38c8285f5236 100644 --- a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp @@ -30,13 +30,11 @@ int main() { { typedef std::unordered_multimap<int, std::string> C; - typedef std::pair<int, std::string> P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multimap<int, std::string> C; - typedef std::pair<int, std::string> P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); @@ -46,14 +44,12 @@ int main() { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef std::pair<int, std::string> P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef std::pair<int, std::string> P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp index 0f898f1b73e0..8c5ddab054e5 100644 --- a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp @@ -34,7 +34,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -219,7 +218,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -404,7 +402,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp index e404612a754e..d924ef15c1a3 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,22 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp index b5f4403174b8..2fbe7a674273 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +54,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp index b621449f2b74..2d5766946a6f 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +55,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp index 94067c3161e2..7f3a337bddc4 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,27 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp index 7a58709c9fc9..33d8e3c36361 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -64,6 +64,7 @@ struct some_hash typedef T value_type; some_hash() {} some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; template <class T> @@ -72,6 +73,7 @@ struct some_hash2 typedef T value_type; some_hash2() {} some_hash2(const some_hash2&); + std::size_t operator()(T const&) const; }; #if TEST_STD_VER >= 14 @@ -124,16 +126,18 @@ int main() typedef std::unordered_multimap<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -177,9 +181,11 @@ int main() typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<V>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<V>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp index 06e6c65c991d..644af867dad4 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp @@ -33,7 +33,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -218,7 +217,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -403,7 +401,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp index ec4d0e675501..c60a811678fb 100644 --- a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp @@ -25,14 +25,11 @@ int main() { { typedef std::unordered_multiset<int> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_multiset<int> C; - typedef C::const_iterator I; typedef int P; P a[] = { @@ -52,15 +49,12 @@ int main() { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; typedef int P; P a[] = { diff --git a/test/std/containers/unord/unord.multiset/incomplete.pass.cpp b/test/std/containers/unord/unord.multiset/incomplete.pass.cpp index f6d8dc17c5a2..1b3c1492c4a4 100644 --- a/test/std/containers/unord/unord.multiset/incomplete.pass.cpp +++ b/test/std/containers/unord/unord.multiset/incomplete.pass.cpp @@ -11,7 +11,7 @@ // <unordered_set> -// Check that std::unordered_multiset and it's iterators can be instantiated with an incomplete +// Check that std::unordered_multiset and its iterators can be instantiated with an incomplete // type. #include <unordered_set> diff --git a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp index fad1c182e6b7..df2cb7beff39 100644 --- a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp @@ -43,7 +43,6 @@ int main() } { typedef std::unordered_multiset<int> C; - typedef int P; const C c; assert(c.load_factor() == 0); } @@ -69,7 +68,6 @@ int main() { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp index 00fe962327f8..f7ebaaf65d47 100644 --- a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp @@ -29,13 +29,11 @@ int main() { { typedef std::unordered_multiset<int> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multiset<int> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); @@ -45,14 +43,12 @@ int main() { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp index c0c9e9021712..9ffe3ad480be 100644 --- a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp index fba024aed00e..3b69c1eed2e3 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,22 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp index 62fe51e29903..1e927b9b3958 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +54,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp index ac0a10a4b0ea..7336bb5afa7c 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +55,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp index e44be18fa3b4..fcf2a5af3129 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,27 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp index c221b6f2edb0..4afef42e6a60 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp @@ -125,16 +125,18 @@ int main() typedef std::unordered_multiset<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -178,10 +180,11 @@ int main() typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp index d4efb6868026..ce290ff1c1e7 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.set/bucket_count.pass.cpp b/test/std/containers/unord/unord.set/bucket_count.pass.cpp index 6f1f526abaf6..227d9e123331 100644 --- a/test/std/containers/unord/unord.set/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.set/bucket_count.pass.cpp @@ -25,14 +25,11 @@ int main() { { typedef std::unordered_set<int> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_set<int> C; - typedef C::const_iterator I; typedef int P; P a[] = { @@ -51,14 +48,11 @@ int main() #if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; typedef int P; P a[] = { diff --git a/test/std/containers/unord/unord.set/incomplete.pass.cpp b/test/std/containers/unord/unord.set/incomplete.pass.cpp index c970c1de5531..4f7a00c999e8 100644 --- a/test/std/containers/unord/unord.set/incomplete.pass.cpp +++ b/test/std/containers/unord/unord.set/incomplete.pass.cpp @@ -11,7 +11,7 @@ // <unordered_set> -// Check that std::unordered_set and it's iterators can be instantiated with an incomplete +// Check that std::unordered_set and its iterators can be instantiated with an incomplete // type. #include <unordered_set> diff --git a/test/std/containers/unord/unord.set/load_factor.pass.cpp b/test/std/containers/unord/unord.set/load_factor.pass.cpp index a342d472a3d5..94eb5d1bd04b 100644 --- a/test/std/containers/unord/unord.set/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/load_factor.pass.cpp @@ -43,7 +43,6 @@ int main() } { typedef std::unordered_set<int> C; - typedef int P; const C c; assert(c.load_factor() == 0); } @@ -69,7 +68,6 @@ int main() { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp index 542788cca967..e9e04bca8562 100644 --- a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp @@ -29,13 +29,11 @@ int main() { { typedef std::unordered_set<int> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_set<int> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); @@ -45,14 +43,12 @@ int main() { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.set/swap_member.pass.cpp b/test/std/containers/unord/unord.set/swap_member.pass.cpp index ea88c53a526c..597662112cef 100644 --- a/test/std/containers/unord/unord.set/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.set/swap_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp index 3dcc3247902e..b8d06dbfdd16 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,22 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp index 82e184b8d3ea..4c10ed2d6290 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +54,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp index b89d68002477..670a3484d15f 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +55,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp index 7190a01208f0..43e06bd50463 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,27 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp index 4a16ddd3f4ce..7187f94a28dc 100644 --- a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp @@ -125,16 +125,18 @@ int main() typedef std::unordered_set<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -178,10 +180,11 @@ int main() typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp index c2bd75960d5b..9ca2f80f0561 100644 --- a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp index 2c6acb5af12c..a5d52a6ef778 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr& operator=(auto_ptr& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp index aeea7dec9e34..cce3c79ef5ba 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp index 6809073c2d0c..b83c266fb9b2 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp index 27ba0e513e45..10a432647199 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp index e29ff2e78244..3dfd200fafa9 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp @@ -13,6 +13,8 @@ // explicit auto_ptr(X* p =0) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp index 6f53581af422..91801efac64a 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr& operator=(auto_ptr_ref<X> r) throw() +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp index 375780527cf0..e08df64377d5 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr_ref<X> r) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp index 00c0f6d30caf..572e5e686d49 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> operator auto_ptr<Y>() throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp index a5db81e6c632..cd9fed2fb10e 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> operator auto_ptr_ref<Y>() throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp index fce9332df846..305cf025ce45 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp @@ -13,6 +13,8 @@ // X& operator*() const throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp index dd5669563e35..7174b27fb862 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp @@ -13,6 +13,8 @@ // X& operator*() const throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp index 5860eb411143..650da2ef8196 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp @@ -16,6 +16,8 @@ #include <memory> #include <cassert> +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include "../A.h" void diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp index cdbdd73ab72d..55772b68808d 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp @@ -16,6 +16,8 @@ #include <memory> #include <cassert> +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include "../A.h" void diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp index 256563439a17..1895828aff64 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp @@ -17,6 +17,8 @@ // ... // }; +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <type_traits> diff --git a/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/test/std/depr/depr.c.headers/stdio_h.pass.cpp index 85f9d2986284..36c37a3beb3e 100644 --- a/test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -99,7 +99,7 @@ #include <cstdarg> -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic ignored "-Wformat-zero-length" #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam #endif @@ -107,7 +107,7 @@ int main() { FILE* fp = 0; - fpos_t fpos = {}; + fpos_t fpos = fpos_t(); size_t s = 0; char* cp = 0; char arr[] = {'a', 'b'}; diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp new file mode 100644 index 000000000000..fc37c9a59797 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// pointer_to_binary_function +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +double binary_f(int i, short j) {return i - j + .75;} + +int main() +{ + typedef std::pointer_to_binary_function<int, short, double> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp index 41c99998caeb..e47731a65133 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // pointer_to_binary_function diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp new file mode 100644 index 000000000000..687a819a392d --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// pointer_to_unary_function +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +double unary_f(int i) {return 0.5 - i;} + +int main() +{ + typedef std::pointer_to_unary_function<int, double> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp index 126cf32af436..2d713b3beed2 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // pointer_to_unary_function diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp new file mode 100644 index 000000000000..2d232193607b --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template <CopyConstructible Arg, Returnable Result> +// pointer_to_unary_function<Arg, Result> +// ptr_fun(Result (*f)(Arg)); +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +double unary_f(int i) {return 0.5 - i;} + +int main() +{ + assert(std::ptr_fun(unary_f)(36) == -35.5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp index c7ce90df3eb7..65f2a8d34253 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <CopyConstructible Arg, Returnable Result> // pointer_to_unary_function<Arg, Result> diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp index ed94c1a1e470..202abe25e008 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp @@ -7,22 +7,22 @@ // //===----------------------------------------------------------------------===// -// <memory> +// <functional> -// unique_ptr +// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result> +// pointer_to_binary_function<Arg1,Arg2,Result> +// ptr_fun(Result (*f)(Arg1, Arg2)); +// UNSUPPORTED: c++98, c++03, c++11, c++14 -// Test unique_ptr move assignment - -#include <memory> +#include <functional> +#include <type_traits> +#include <cassert> #include "test_macros.h" +double binary_f(int i, short j) {return i - j + .75;} + int main() { - std::unique_ptr<int> s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member of 'std::__1::unique_ptr}} -#endif + assert(std::ptr_fun(binary_f)(36, 27) == 9.75); } diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp index 17c4b611a319..5628c026c95a 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result> // pointer_to_binary_function<Arg1,Arg2,Result> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp new file mode 100644 index 000000000000..1c56aa9f5dc5 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<cReturnable S, ClassType T> +// const_mem_fun_t<S,T> +// mem_fun(S (T::*f)() const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun(&A::a3)(&a) == 1); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp index 455eed9b3e3c..4693c816c338 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<cReturnable S, ClassType T> // const_mem_fun_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp new file mode 100644 index 000000000000..c727e955b1d5 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// const_mem_fun1_t<S,T,A> +// mem_fun(S (T::*f)(A) const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun(&A::a4)(&a, 6) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp index 46fd6d28d514..9f0b605d9a91 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // const_mem_fun1_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..39b3112da94c --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun1_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun1_ref_t<double, A, unsigned> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp index 0c4bb93ff524..65fc8c07eb2c 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun1_ref_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..f07a3b798e72 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun1_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun1_t<double, A, unsigned> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp index ca670bcde109..71588fa1f9d3 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun1_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp new file mode 100644 index 000000000000..fea1441b31f1 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T> +// const_mem_fun_ref_t<S,T> +// mem_fun_ref(S (T::*f)() const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun_ref(&A::a3)(a) == 1); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp index 74d8950dea7f..22f44c65cd6a 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T> // const_mem_fun_ref_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp new file mode 100644 index 000000000000..f993b7ce1949 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// const_mem_fun1_ref_t<S,T,A> +// mem_fun_ref(S (T::*f)(A) const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun_ref(&A::a4)(a, 6) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp index b858561ae757..267b80681eaf 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // const_mem_fun1_ref_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..e195213f9c02 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun_ref_t<int, A> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp index 9eec24e5743c..6f80993cbcdf 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun_ref_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..228eb3da60a6 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun_t<int, A> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp index 9681b74d7e61..01945fc46f9f 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp new file mode 100644 index 000000000000..8f59a1ae2f82 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T> +// mem_fun_t<S,T> +// mem_fun(S (T::*f)()); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun(&A::a1)(&a) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp index d0d286009ada..f3c12973fc8b 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T> // mem_fun_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp new file mode 100644 index 000000000000..6191de3fbe63 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// mem_fun1_t<S,T,A> +// mem_fun(S (T::*f)(A)); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun(&A::a2)(&a, 5) == 6); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp index acee9afeec7a..30f3c9422d2b 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // mem_fun1_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..0effd33f3784 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// mem_fun1_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::mem_fun1_ref_t<short, A, int> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp index a78cbf25c191..0b63bb76ddb7 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun1_ref_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..aa8e25abe438 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// mem_fun1_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::mem_fun1_t<short, A, int> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp index 90ba9bbf788d..79895c4b4d89 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun1_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp new file mode 100644 index 000000000000..ff7f28af8e30 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T> +// mem_fun_ref_t<S,T> +// mem_fun_ref(S (T::*f)()); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun_ref(&A::a1)(a) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp index d3843fc5344c..8a6a8b943e4b 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T> // mem_fun_ref_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp new file mode 100644 index 000000000000..82d47fefd3d4 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// mem_fun1_ref_t<S,T,A> +// mem_fun_ref(S (T::*f)(A)); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun_ref(&A::a2)(a, 5) == 6); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp index 39a324d10bc4..142b16a6b3e4 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // mem_fun1_ref_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp new file mode 100644 index 000000000000..f1cf01c5c424 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// mem_fun_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::mem_fun_ref_t<char, A> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp index 236d8d0945fb..5af028b39928 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun_ref_t diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp index 6e13873c2fb3..e6a1ed330762 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp @@ -7,33 +7,27 @@ // //===----------------------------------------------------------------------===// -// <memory> +// <functional> -// unique_ptr +// mem_fun_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 -// Test unique_ptr move assignment - -#include <memory> -#include <utility> +#include <functional> +#include <type_traits> #include <cassert> -// Can't copy from const lvalue +#include "test_macros.h" struct A { - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} }; -int A::count = 0; - int main() { - { - const std::unique_ptr<A[]> s(new A[3]); - std::unique_ptr<A[]> s2; - s2 = s; - } + typedef std::mem_fun_t<char, A> F; } diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp index 3fc84cd05c63..c33e2f7d753f 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun_t diff --git a/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp index b6b75263c602..796e4ad878be 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn, class T> // binder1st<Fn> diff --git a/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp index b7feb243b839..cbf1dbf9fbd9 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn, class T> // binder2nd<Fn> diff --git a/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp index 8b7aaf0fdae1..480148b7658e 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn> // class binder1st diff --git a/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp index 645c1688c18a..3dfb1f02d2a2 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn> // class binder2nd diff --git a/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp b/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp index 02f9a81aa6dd..5c596da5a0bc 100644 --- a/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp +++ b/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test get_unexpected #include <exception> diff --git a/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp b/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp index ed02fa618e8e..9b9d726f7f3c 100644 --- a/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp +++ b/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test set_unexpected #include <exception> diff --git a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp index 5879529317ef..f6bc5bc5a68c 100644 --- a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp +++ b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test unexpected_handler #include <exception> diff --git a/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp b/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp index 03b484f7631a..92d4d38e272b 100644 --- a/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp +++ b/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test unexpected #include <exception> diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp index af7f27f73fc5..8a9a1a232d0d 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp +++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp @@ -7,23 +7,24 @@ // //===----------------------------------------------------------------------===// -// <memory> +// XFAIL: c++98, c++03 -// unique_ptr +// <system_error> -// Test unique_ptr<T[]>(pointer) ctor +// class error_code -#include <memory> +// explicit operator bool() const; -// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: +#include <system_error> - void operator()(void*) {} -}; +bool test_func(void) +{ + const std::error_code ec(0, std::generic_category()); + return ec; // conversion to bool is explicit; should fail. +} int main() { - std::unique_ptr<int[], Deleter&> p(new int); + return 0; } + diff --git a/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp new file mode 100644 index 000000000000..f1b460575917 --- /dev/null +++ b/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <system_error> + +// Test that <system_error> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <system_error> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::error_code>(); + test_hash_enabled_for_type<std::error_condition>(); + } +} diff --git a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp index 4091f446af27..dac13bdb83c8 100644 --- a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp @@ -29,6 +29,7 @@ test(int i) typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; T ec(i, std::system_category()); const std::size_t result = h(ec); diff --git a/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp index d455210c2697..eef37c68b6f0 100644 --- a/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp @@ -29,6 +29,7 @@ test(int i) typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; T ec(i, std::system_category()); const std::size_t result = h(ec); diff --git a/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp b/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp index 531731791c5d..23098d83e4ea 100644 --- a/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp +++ b/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp @@ -58,19 +58,23 @@ void test() { const unsigned os = Expectations::os; SampleItem oa[os]; const int *oa1 = Expectations::oa1; + ((void)oa1); // Prevent unused warning const int *oa2 = Expectations::oa2; + ((void)oa2); // Prevent unused warning std::minstd_rand g; SampleIterator end; end = std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), SampleIterator(oa), os, g); - assert(end.base() - oa == std::min(os, is)); - assert(std::equal(oa, oa + os, oa1)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + // sample() is deterministic but non-reproducible; + // its results can vary between implementations. + LIBCPP_ASSERT(std::equal(oa, oa + os, oa1)); end = std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), SampleIterator(oa), os, std::move(g)); - assert(end.base() - oa == std::min(os, is)); - assert(std::equal(oa, oa + os, oa2)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + LIBCPP_ASSERT(std::equal(oa, oa + os, oa2)); } template <template<class...> class PopulationIteratorType, class PopulationItem, @@ -119,7 +123,7 @@ void test_small_population() { end = std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), SampleIterator(oa), os, g); - assert(end.base() - oa == std::min(os, is)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); assert(std::equal(oa, end.base(), oa1)); } diff --git a/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp b/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp index 585b0bb1dd5e..a744e659f5b5 100644 --- a/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp +++ b/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp @@ -30,8 +30,8 @@ int main() { { static_assert(std::is_nothrow_default_constructible<file_status>::value, "The default constructor must be noexcept"); - static_assert(!test_convertible<file_status>(), - "The default constructor must be explicit"); + static_assert(test_convertible<file_status>(), + "The default constructor must not be explicit"); const file_status f; assert(f.type() == file_type::none); assert(f.permissions() == perms::unknown); diff --git a/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp index f344e1153071..a6172d1981cf 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp @@ -131,7 +131,7 @@ void doAppendSourceAllocTest(AppendOperatorTestcase const& TC) assert(LHS == E); } // input iterator - For non-native char types, appends needs to copy the - // iterator range into a contigious block of memory before it can perform the + // iterator range into a contiguous block of memory before it can perform the // code_cvt conversions. // For "char" no allocations will be performed because no conversion is // required. diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp index a4bd2cba1cef..c5da52f65248 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp @@ -7,29 +7,26 @@ // //===----------------------------------------------------------------------===// -// <memory> +// UNSUPPORTED: c++98, c++03 -// unique_ptr +// <experimental/filesystem> -// Test unique_ptr converting move ctor +// class path -// Do not convert from an array unique_ptr +// path& operator=(path const&); -#include <memory> -#include <utility> +#include <experimental/filesystem> +#include <type_traits> #include <cassert> -struct A -{ -}; +#include "test_macros.h" +#include "count_new.hpp" -struct Deleter -{ - void operator()(void*) {} -}; +namespace fs = std::experimental::filesystem; -int main() -{ - std::unique_ptr<A[], Deleter> s; - std::unique_ptr<A, Deleter> s2(std::move(s)); +int main() { + using namespace fs; + path p("abc"); + p = {}; + assert(p.native() == ""); } diff --git a/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp index 9e48cbf1e7f2..8c31ef51d944 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp @@ -15,6 +15,7 @@ // template <class Source> // path& operator=(Source const&); +// path& operator=(string_type&&); // template <class Source> // path& assign(Source const&); // template <class InputIterator> @@ -49,7 +50,7 @@ void RunTestCase(MultiStringType const& MS) { const std::basic_string<CharT> S(TestPath); path p; PathReserve(p, S.length() + 1); { - // string provides a contigious iterator. No allocation needed. + // string provides a contiguous iterator. No allocation needed. DisableAllocationGuard g; path& pref = (p = S); assert(&pref == &p); @@ -75,7 +76,7 @@ void RunTestCase(MultiStringType const& MS) { const std::basic_string_view<CharT> S(TestPath); path p; PathReserve(p, S.length() + 1); { - // string provides a contigious iterator. No allocation needed. + // string provides a contiguous iterator. No allocation needed. DisableAllocationGuard g; path& pref = (p = S); assert(&pref == &p); @@ -101,7 +102,7 @@ void RunTestCase(MultiStringType const& MS) { { path p; PathReserve(p, Size + 1); { - // char* pointers are contigious and can be used with code_cvt directly. + // char* pointers are contiguous and can be used with code_cvt directly. // no allocations needed. DisableAllocationGuard g; path& pref = (p = TestPath); @@ -213,12 +214,29 @@ void test_sfinae() { } } +void RunStringMoveTest(const char* Expect) { + using namespace fs; + std::string ss(Expect); + path p; + { + DisableAllocationGuard g; ((void)g); + path& pr = (p = std::move(ss)); + assert(&pr == &p); + } + assert(p == Expect); + { + // Signature test + ASSERT_NOEXCEPT(p = std::move(ss)); + } +} + int main() { for (auto const& MS : PathList) { RunTestCase<char>(MS); RunTestCase<wchar_t>(MS); RunTestCase<char16_t>(MS); RunTestCase<char32_t>(MS); + RunStringMoveTest(MS); } test_sfinae(); } diff --git a/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp index 89269362d06f..76df0e9eef76 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp @@ -132,7 +132,7 @@ void doConcatSourceAllocTest(ConcatOperatorTestcase const& TC) assert(LHS == E); } // input iterator - For non-native char types, appends needs to copy the - // iterator range into a contigious block of memory before it can perform the + // iterator range into a contiguous block of memory before it can perform the // code_cvt conversions. // For "char" no allocations will be performed because no conversion is // required. diff --git a/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp index 4c83481aaf2d..078e006663e9 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp @@ -54,12 +54,6 @@ #include "count_new.hpp" #include "filesystem_test_helper.hpp" -template <class It> -std::reverse_iterator<It> mkRev(It it) { - return std::reverse_iterator<It>(it); -} - - namespace fs = std::experimental::filesystem; struct PathDecomposeTestcase { @@ -147,7 +141,11 @@ void decompPathTest() assert(checkCollectionsEqual(p.begin(), p.end(), TC.elements.begin(), TC.elements.end())); // check backwards - assert(checkCollectionsEqual(mkRev(p.end()), mkRev(p.begin()), + + std::vector<fs::path> Parts; + for (auto it = p.end(); it != p.begin(); ) + Parts.push_back(*--it); + assert(checkCollectionsEqual(Parts.begin(), Parts.end(), TC.elements.rbegin(), TC.elements.rend())); } } diff --git a/test/std/experimental/filesystem/class.path/synop.pass.cpp b/test/std/experimental/filesystem/class.path/synop.pass.cpp index b0a7b5cd65e2..883feb287d06 100644 --- a/test/std/experimental/filesystem/class.path/synop.pass.cpp +++ b/test/std/experimental/filesystem/class.path/synop.pass.cpp @@ -32,7 +32,7 @@ int main() { { ASSERT_SAME_TYPE(const path::value_type, decltype(path::preferred_separator)); static_assert(path::preferred_separator == '/', ""); - // Make preferred_separator ODR used by taking it's address. + // Make preferred_separator ODR used by taking its address. const char* dummy = &path::preferred_separator; ((void)dummy); } diff --git a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp index e67fc2f20f6e..26fc3ca28d8e 100644 --- a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp +++ b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp @@ -175,7 +175,7 @@ TEST_CASE(access_denied_on_recursion_test_case) TEST_CHECK(ec); TEST_CHECK(it == endIt); } - // Same as obove but test operator++(). + // Same as above but test operator++(). { std::error_code ec = GetTestEC(); recursive_directory_iterator it(startDir, ec); @@ -222,7 +222,7 @@ TEST_CASE(access_denied_on_recursion_test_case) TEST_REQUIRE(ec); TEST_REQUIRE(it == endIt); } - // Same as obove but testing the throwing constructors + // Same as above but testing the throwing constructors { TEST_REQUIRE_THROW(filesystem_error, recursive_directory_iterator(permDeniedDir)); diff --git a/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp b/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp index d8d92c5888ac..447fb46e840b 100644 --- a/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp +++ b/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp @@ -18,8 +18,8 @@ #include <type_traits> // system_clock is used because it meets the requirements of TrivialClock, -// and it's resolution and range of system_clock should match the operating -// systems file time type. +// and the resolution and range of system_clock should match the operating +// system's file time type. typedef std::chrono::system_clock ExpectedClock; typedef std::chrono::time_point<ExpectedClock> ExpectedTimePoint; diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp index 4d59235c722b..28e945b68970 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp @@ -54,7 +54,7 @@ TEST_CASE(absolute_path_test) TEST_REQUIRE(not p.has_root_name()); TEST_REQUIRE(p.has_root_directory()); TEST_CHECK(p.is_absolute()); - // ensure absolute(base) is not recursivly called + // ensure absolute(base) is not recursively called TEST_REQUIRE(base.has_root_name()); TEST_REQUIRE(base.has_root_directory()); @@ -73,7 +73,7 @@ TEST_CASE(absolute_path_test) TEST_REQUIRE(p.has_root_name()); TEST_REQUIRE(not p.has_root_directory()); TEST_CHECK(not p.is_absolute()); - // absolute is called recursivly on base. The following conditions + // absolute is called recursively on base. The following conditions // must be true for it to return base unmodified TEST_REQUIRE(base.has_root_name()); TEST_REQUIRE(base.has_root_directory()); diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp index 252ced6fd65f..2b9f57e7e954 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp @@ -85,4 +85,13 @@ TEST_CASE(test_exists_fails) TEST_CHECK_THROW(filesystem_error, exists(file)); } +TEST_CASE(test_name_too_long) { + std::string long_name(2500, 'a'); + const path file(long_name); + + std::error_code ec; + TEST_CHECK(exists(file, ec) == false); + TEST_CHECK(ec); +} + TEST_SUITE_END() diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp index 4177392141e5..794aeb992640 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp @@ -144,7 +144,7 @@ TEST_CASE(test_no_resolve_symlink_on_symlink) std::error_code expected_ec; #else // On linux symlink permissions are not supported. The error code should - // be 'operation_not_supported' and the sylink permissions should be + // be 'operation_not_supported' and the symlink permissions should be // unchanged. const auto expected_link_perms = symlink_status(sym).permissions(); std::error_code expected_ec = std::make_error_code(std::errc::operation_not_supported); diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp index 2c76caf74c84..fdc3d2b4a61f 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp @@ -65,29 +65,36 @@ TEST_CASE(test_status_cannot_resolve) const std::error_code set_ec = std::make_error_code(std::errc::address_in_use); - const std::error_code expect_ec = + const std::error_code perm_ec = std::make_error_code(std::errc::permission_denied); + const std::error_code name_too_long_ec = + std::make_error_code(std::errc::filename_too_long); - const path cases[] = { - file, sym + struct TestCase { + path p; + std::error_code expect_ec; + } const TestCases[] = { + {file, perm_ec}, + {sym, perm_ec}, + {path(std::string(2500, 'a')), name_too_long_ec} }; - for (auto& p : cases) + for (auto& TC : TestCases) { { // test non-throwing case std::error_code ec = set_ec; - file_status st = status(p, ec); - TEST_CHECK(ec == expect_ec); + file_status st = status(TC.p, ec); + TEST_CHECK(ec == TC.expect_ec); TEST_CHECK(st.type() == file_type::none); TEST_CHECK(st.permissions() == perms::unknown); } #ifndef TEST_HAS_NO_EXCEPTIONS { // test throwing case try { - status(p); + status(TC.p); } catch (filesystem_error const& err) { - TEST_CHECK(err.path1() == p); + TEST_CHECK(err.path1() == TC.p); TEST_CHECK(err.path2() == ""); - TEST_CHECK(err.code() == expect_ec); + TEST_CHECK(err.code() == TC.expect_ec); } } #endif diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp index 148564e61961..021dd7fc8160 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp @@ -97,6 +97,14 @@ TEST_CASE(basic_tests) TEST_CHECK(ec == std::make_error_code(std::errc::permission_denied)); TEST_CHECK(ret == ""); + // Set the env variable to point to a non-existent dir + PutEnv(TC.name, TC.p / "does_not_exist"); + ec = GetTestEC(); + ret = temp_directory_path(ec); + TEST_CHECK(ec != GetTestEC()); + TEST_CHECK(ec); + TEST_CHECK(ret == ""); + // Finally erase this env variable UnsetEnv(TC.name); } diff --git a/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp b/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp index a02dcf336960..3e83173555be 100644 --- a/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp +++ b/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp @@ -120,7 +120,7 @@ void test_pmr_uses_alloc(Args&&... args) } { // Test that T(std::allocator_arg_t, Alloc const&, Args...) construction - // is prefered when T(Args..., Alloc const&) is also available. + // is preferred when T(Args..., Alloc const&) is also available. using T = UsesAllocatorV3<Alloc, sizeof...(Args)>; assert((doTest<T>(UA_AllocArg, std::forward<Args>(args)...))); } diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool1.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool1.fail.cpp new file mode 100644 index 000000000000..c8d6c5367d7e --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool1.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool2.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool2.fail.cpp new file mode 100644 index 000000000000..a3a2206fba63 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool2.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool3.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool3.fail.cpp new file mode 100644 index 000000000000..1f04580ddabd --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool3.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd<volatile bool, int>(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool4.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool4.fail.cpp new file mode 100644 index 000000000000..1f0e8a2b3a2f --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool4.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd<int, const bool>(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index a52b50b391cd..3f86cfe4c7f0 100644 --- a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -129,4 +129,11 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2792 + { + auto res = std::experimental::gcd((int64_t)1234, (int32_t)-2147483648); + static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res == 2); + } } diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool1.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool1.fail.cpp new file mode 100644 index 000000000000..e4c2ed8bf539 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool1.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool2.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool2.fail.cpp new file mode 100644 index 000000000000..097b23eae6e4 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool2.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool3.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool3.fail.cpp new file mode 100644 index 000000000000..d5e6300818cc --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool3.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm<volatile bool, int>(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool4.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool4.fail.cpp new file mode 100644 index 000000000000..d88c490d64bf --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool4.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm<int, const bool>(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp index e3c109f7447b..fd463e88e63f 100644 --- a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -128,4 +128,12 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2792 + { + auto res1 = std::experimental::lcm((int64_t)1234, (int32_t)-2147483648); + (void) std::experimental::lcm<int, unsigned long>(INT_MIN, 2); // this used to trigger UBSAN + static_assert( std::is_same<decltype(res1), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res1 == 1324997410816LL); + } } diff --git a/test/std/experimental/string.view/lit.local.cfg b/test/std/experimental/string.view/lit.local.cfg new file mode 100644 index 000000000000..376dbe7c16ec --- /dev/null +++ b/test/std/experimental/string.view/lit.local.cfg @@ -0,0 +1,3 @@ +# Disable all of the filesystem tests if the correct feature is not available. +if 'msvc' in config.available_features: + config.unsupported = True diff --git a/test/std/experimental/string.view/string.view.access/at.pass.cpp b/test/std/experimental/string.view/string.view.access/at.pass.cpp index 7ceaf5ab3d9f..eaea062987fb 100644 --- a/test/std/experimental/string.view/string.view.access/at.pass.cpp +++ b/test/std/experimental/string.view/string.view.access/at.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// NOTE: Older versions of clang have a bug where they fail to evalute +// NOTE: Older versions of clang have a bug where they fail to evaluate // string_view::at as a constant expression. // XFAIL: clang-3.4, clang-3.3 diff --git a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp index 0c5170f29cea..57dff44976bc 100644 --- a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp +++ b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp @@ -13,7 +13,7 @@ // template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) -// Testing extended function types. The extented function types are those +// Testing extended function types. The extended function types are those // named by INVOKE but that are not actual callable objects. These include // bullets 1-4 of invoke. diff --git a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp index 5df8691ef1f9..1f1b0c3faa5b 100644 --- a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp +++ b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp @@ -89,7 +89,7 @@ int main() { std::FILE* fp = 0; - std::fpos_t fpos = {}; + std::fpos_t fpos = std::fpos_t(); std::size_t s = 0; char* cp = 0; std::va_list va; diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp index ed68279d7b57..3095712b9dbc 100644 --- a/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp +++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp @@ -12,7 +12,7 @@ // basic_istream<charT,traits>& // ignore(streamsize n = 1, int_type delim = traits::eof()); -// http://llvm.org/bugs/show_bug.cgi?id=16427 +// https://bugs.llvm.org/show_bug.cgi?id=16427 #include <sstream> #include <cassert> diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp index e68fb774335d..e09c0ed20461 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp @@ -23,6 +23,7 @@ #include <sstream> #include <ios> +#include <type_traits> #include <cctype> #include <cstdint> #include <cassert> @@ -66,11 +67,15 @@ int main() test_octal<uint64_t>("1777777777777777777777"); test_octal< int64_t>("1777777777777777777777"); test_octal<uint64_t>("1777777777777777777777"); - if (sizeof(long) == sizeof(int64_t)) { + + const bool long_is_64 = std::integral_constant<bool, sizeof(long) == sizeof(int64_t)>::value; // avoid compiler warnings + const bool long_long_is_64 = std::integral_constant<bool, sizeof(long long) == sizeof(int64_t)>::value; // avoid compiler warnings + + if (long_is_64) { test_octal< unsigned long>("1777777777777777777777"); test_octal< long>("1777777777777777777777"); } - if (sizeof(long long) == sizeof(int64_t)) { + if (long_long_is_64) { test_octal< unsigned long long>("1777777777777777777777"); test_octal< long long>("1777777777777777777777"); } @@ -81,11 +86,11 @@ int main() test_dec< int32_t>( "-1"); test_dec<uint64_t>("18446744073709551615"); test_dec< int64_t>( "-1"); - if (sizeof(long) == sizeof(int64_t)) { + if (long_is_64) { test_dec<unsigned long>("18446744073709551615"); test_dec< long>( "-1"); } - if (sizeof(long long) == sizeof(int64_t)) { + if (long_long_is_64) { test_dec<unsigned long long>("18446744073709551615"); test_dec< long long>( "-1"); } @@ -96,11 +101,11 @@ int main() test_hex< int32_t>( "FFFFFFFF"); test_hex<uint64_t>("FFFFFFFFFFFFFFFF"); test_hex< int64_t>("FFFFFFFFFFFFFFFF"); - if (sizeof(long) == sizeof(int64_t)) { + if (long_is_64) { test_hex<unsigned long>("FFFFFFFFFFFFFFFF"); test_hex< long>("FFFFFFFFFFFFFFFF"); } - if (sizeof(long long) == sizeof(int64_t)) { + if (long_long_is_64) { test_hex<unsigned long long>("FFFFFFFFFFFFFFFF"); test_hex< long long>("FFFFFFFFFFFFFFFF"); } diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp index ec3fe48866c7..bed0d72af809 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp @@ -56,7 +56,7 @@ int main() assert(seekpos_called == 2); assert(os.fail()); } - { // See https://llvm.org/bugs/show_bug.cgi?id=21361 + { // See https://bugs.llvm.org/show_bug.cgi?id=21361 seekpos_called = 0; testbuf<char> sb; std::ostream os(&sb); diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp index ebfd24af91d5..eb76cbf9d28a 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp @@ -58,7 +58,7 @@ int main() assert(seekoff_called == 2); assert(os.fail()); } - { // See https://llvm.org/bugs/show_bug.cgi?id=21361 + { // See https://bugs.llvm.org/show_bug.cgi?id=21361 seekoff_called = 0; testbuf<char> sb; std::ostream os(&sb); diff --git a/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp b/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp index c9fccea2c7d0..6b550b5dabe4 100644 --- a/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp +++ b/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" -// Test that mismatches between strings and wides streams are diagnosed +// Test that mismatches between strings and wide streams are diagnosed #if TEST_STD_VER > 11 diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp index 1e2ee50632af..59f0bd478760 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp @@ -13,6 +13,9 @@ // long& iword(int idx); +// This test compiles but never completes when compiled against the MSVC STL +// UNSUPPORTED: msvc + #include <ios> #include <string> #include <cassert> diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp index 5246ad8f644c..45115823b4c2 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp @@ -13,6 +13,9 @@ // void*& pword(int idx); +// This test compiles but never completes when compiled against the MSVC STL +// UNSUPPORTED: msvc + #include <ios> #include <string> #include <cassert> diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp index a3c11f7881a9..d5df1b7c094e 100644 --- a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp +++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <iterator> // back_insert_iterator @@ -17,8 +19,6 @@ #include <iterator> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - #include <vector> #include <memory> #include <cassert> @@ -32,11 +32,7 @@ test(C c) assert(c.back() == typename C::value_type()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test(std::vector<std::unique_ptr<int> >()); -#endif } diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp index bd2bd44837ab..af880f871ff5 100644 --- a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp +++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <iterator> // front_insert_iterator @@ -15,9 +17,6 @@ // operator=(Cont::value_type&& value); #include <iterator> - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - #include <list> #include <memory> #include <cassert> @@ -31,11 +30,7 @@ test(C c) assert(c.front() == typename C::value_type()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test(std::list<std::unique_ptr<int> >()); -#endif } diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp index f771688f1adc..ad1fa29ac7cf 100644 --- a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp +++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <iterator> // insert_iterator @@ -17,7 +19,6 @@ #include <iterator> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <utility> #include <vector> #include <memory> @@ -52,11 +53,8 @@ struct do_nothing void operator()(void*) const {} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unique_ptr<int, do_nothing> Ptr; typedef std::vector<Ptr> C; @@ -94,5 +92,4 @@ int main() insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5)); test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp index 7f807b63e3ce..fc6dc0009a0d 100644 --- a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp +++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp @@ -13,7 +13,7 @@ // istream_iterator(const istream_iterator& x); // C++17 says: If is_trivially_copy_constructible_v<T> is true, then -// this constructor shall beis a trivial copy constructor. +// this constructor is a trivial copy constructor. #include <iterator> #include <sstream> diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp index 32dc62817bc4..22f2967f3281 100644 --- a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp +++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// // Usage of is_trivially_constructible is broken with these compilers. -// See https://llvm.org/bugs/show_bug.cgi?id=31016 -// XFAIL: clang-3.7, apple-clang-7, apple-clang-7.0 +// See https://bugs.llvm.org/show_bug.cgi?id=31016 +// XFAIL: clang-3.7, apple-clang-7 && c++1z // <iterator> @@ -17,7 +17,7 @@ // constexpr istream_iterator(); // C++17 says: If is_trivially_default_constructible_v<T> is true, then this -// constructor shall beis a constexpr constructor. +// constructor is a constexpr constructor. #include <iterator> #include <cassert> diff --git a/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp index b1bf75b11958..a680aa3f499b 100644 --- a/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp +++ b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp @@ -29,11 +29,11 @@ // If T is a literal type, then this destructor shall be a trivial destructor. // C++17 says: // If is_trivially_default_constructible_v<T> is true, then -// this constructor (the default ctor) shall beis a constexpr constructor. +// this constructor (the default ctor) is a constexpr constructor. // If is_trivially_copy_constructible_v<T> is true, then -// this constructor (the copy ctor) shall beis a trivial copy constructor. +// this constructor (the copy ctor) is a trivial copy constructor. // If is_trivially_destructible_v<T> is true, then this -// destructor shall beis a trivial destructor. +// destructor is a trivial destructor. // Testing the C++17 ctors for this are in the ctor tests. #include <iterator> diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp index 28da3093f398..ec5d0a445baa 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp @@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std::max_align_t) * 2; int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -44,7 +44,7 @@ struct alignas(OverAligned) A }; void test_max_alloc() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); auto do_test = []() { void* vp = operator new [](std::numeric_limits<std::size_t>::max(), std::align_val_t(OverAligned), diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp index dd4ff46bceb9..5aecc2da0847 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -38,7 +38,7 @@ struct A int main() { #ifndef TEST_HAS_NO_EXCEPTIONS - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); try { void* volatile vp = operator new[] (std::numeric_limits<std::size_t>::max()); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp index 2f51b1990436..c1606b27da79 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -37,7 +37,7 @@ struct A int main() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); #ifndef TEST_HAS_NO_EXCEPTIONS try #endif diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp index ff55ec74e3cd..3925f2f5c313 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp @@ -46,9 +46,11 @@ void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT // selected. struct A { ~A() {} }; +A *volatile x; + int main() { - A* x = new A[3]; + x = new A[3]; assert(0 == delete_called); assert(0 == delete_nothrow_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp index 26f7bc392c79..df002c60a6bb 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -38,7 +38,7 @@ struct A int main() { #ifndef TEST_HAS_NO_EXCEPTIONS - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); try { void* vp = operator new (std::numeric_limits<std::size_t>::max()); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp index fefae51dac93..5ebbc8a1a2d9 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp @@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std::max_align_t) * 2; int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -45,7 +45,7 @@ struct alignas(OverAligned) A void test_throw_max_size() { #ifndef TEST_HAS_NO_EXCEPTIONS - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); try { void* vp = operator new (std::numeric_limits<std::size_t>::max(), diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp index ca8503e8854d..6e2eca314771 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp @@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std::max_align_t) * 2; int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -44,7 +44,7 @@ struct alignas(OverAligned) A }; void test_max_alloc() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); auto do_test = []() { void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::align_val_t(OverAligned), diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp index 757e8ae18a47..d85db6c499e9 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -37,7 +37,7 @@ struct A int main() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); #ifndef TEST_HAS_NO_EXCEPTIONS try #endif diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp index ad15b49483d0..ea6c9367b903 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp @@ -43,9 +43,11 @@ struct A ~A() {A_constructed = false;} }; +A *volatile ap; + int main() { - A* ap = new A; + ap = new A; assert(ap); assert(A_constructed); assert(new_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp index 7369c362fce2..57fb1eb88b6e 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp @@ -44,9 +44,11 @@ void operator delete(void* p, std::size_t) TEST_NOEXCEPT std::free(p); } +int *volatile x; + int main() { - int *x = new int(42); + x = new int(42); assert(0 == unsized_delete_called); assert(0 == unsized_delete_nothrow_called); assert(0 == sized_delete_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp index 6c91f5ceda86..b85b670fa2d4 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp @@ -49,9 +49,11 @@ void operator delete(void* p, std::size_t) TEST_NOEXCEPT std::free(p); } +int *volatile x; + int main() { - int *x = new int(42); + x = new int(42); assert(0 == unsized_delete_called); assert(0 == unsized_delete_nothrow_called); assert(0 == sized_delete_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp index 1b6de2367e10..61fca5f125bf 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp @@ -17,7 +17,7 @@ // NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation. // REQUIRES: fsized-deallocation -// RUN: %build -fsized-deallocation +// RUN: %build -fsized-deallocation -O3 // RUN: %run #if !defined(__cpp_sized_deallocation) diff --git a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp index 57d193a411cc..68cd85038b28 100644 --- a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp @@ -46,12 +46,19 @@ public: C * operator&() const { assert(false); } // should not be called }; +class D : private std::nested_exception {}; + + +class E1 : public std::nested_exception {}; +class E2 : public std::nested_exception {}; +class E : public E1, public E2 {}; + int main() { { try { - A a(3); + A a(3); // not a polymorphic type --> no effect std::rethrow_if_nested(a); assert(true); } @@ -63,6 +70,30 @@ int main() { try { + D s; // inaccessible base class --> no effect + std::rethrow_if_nested(s); + assert(true); + } + catch (...) + { + assert(false); + } + } + { + try + { + E s; // ambiguous base class --> no effect + std::rethrow_if_nested(s); + assert(true); + } + catch (...) + { + assert(false); + } + } + { + try + { throw B(5); } catch (const B& b) diff --git a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp index a86d8bcbe201..26be4db38fba 100644 --- a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -107,6 +107,16 @@ int main() assert(i == 7); } } + { + try + { + std::throw_with_nested("String literal"); + assert(false); + } + catch (const char * s) + { + } + } #if TEST_STD_VER > 11 { try diff --git a/test/std/language.support/support.types/byte.pass.cpp b/test/std/language.support/support.types/byte.pass.cpp new file mode 100644 index 000000000000..aed44f91218f --- /dev/null +++ b/test/std/language.support/support.types/byte.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <type_traits> +#include <test_macros.h> + +// XFAIL: c++98, c++03, c++11, c++14 + +// std::byte is not an integer type, nor a character type. +// It is a distinct type for accessing the bits that ultimately make up object storage. + +static_assert( std::is_pod<std::byte>::value, "" ); +static_assert(!std::is_arithmetic<std::byte>::value, "" ); +static_assert(!std::is_integral<std::byte>::value, "" ); + +static_assert(!std::is_same<std::byte, char>::value, "" ); +static_assert(!std::is_same<std::byte, signed char>::value, "" ); +static_assert(!std::is_same<std::byte, unsigned char>::value, "" ); + +// The standard doesn't outright say this, but it's pretty clear that it has to be true. +static_assert(sizeof(std::byte) == 1, "" ); + +int main () {} diff --git a/test/std/language.support/support.types/byteops/and.assign.pass.cpp b/test/std/language.support/support.types/byteops/and.assign.pass.cpp new file mode 100644 index 000000000000..dec241eb0c41 --- /dev/null +++ b/test/std/language.support/support.types/byteops/and.assign.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte& operator &=(byte l, byte r) noexcept; + + +constexpr std::byte test(std::byte b1, std::byte b2) { + std::byte bret = b1; + return bret &= b2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b &= b), "" ); + + static_assert(std::to_integer<int>(test(b1, b8)) == 0, ""); + static_assert(std::to_integer<int>(test(b1, b9)) == 1, ""); + static_assert(std::to_integer<int>(test(b8, b9)) == 8, ""); + + static_assert(std::to_integer<int>(test(b8, b1)) == 0, ""); + static_assert(std::to_integer<int>(test(b9, b1)) == 1, ""); + static_assert(std::to_integer<int>(test(b9, b8)) == 8, ""); +} diff --git a/test/std/language.support/support.types/byteops/and.pass.cpp b/test/std/language.support/support.types/byteops/and.pass.cpp new file mode 100644 index 000000000000..22da6e3e0d4c --- /dev/null +++ b/test/std/language.support/support.types/byteops/and.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator&(byte l, byte r) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b1 & b8), "" ); + + static_assert(std::to_integer<int>(b1 & b8) == 0, ""); + static_assert(std::to_integer<int>(b1 & b9) == 1, ""); + static_assert(std::to_integer<int>(b8 & b9) == 8, ""); + + static_assert(std::to_integer<int>(b8 & b1) == 0, ""); + static_assert(std::to_integer<int>(b9 & b1) == 1, ""); + static_assert(std::to_integer<int>(b9 & b8) == 8, ""); +} diff --git a/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp b/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp new file mode 100644 index 000000000000..298edb22d249 --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b <<= 2.0; + } + + +int main () { + constexpr std::byte b1 = test(std::byte{1}); +} diff --git a/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp b/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp new file mode 100644 index 000000000000..f7e0dee9c6bb --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b <<= 2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b2{2}; + constexpr std::byte b3{3}; + + static_assert(noexcept(b <<= 2), "" ); + + static_assert(std::to_integer<int>(test(b2)) == 8, "" ); + static_assert(std::to_integer<int>(test(b3)) == 12, "" ); + +} diff --git a/test/std/language.support/support.types/byteops/lshift.fail.cpp b/test/std/language.support/support.types/byteops/lshift.fail.cpp new file mode 100644 index 000000000000..c950329334be --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator <<(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2 = b1 << 2.0f; +} diff --git a/test/std/language.support/support.types/byteops/lshift.pass.cpp b/test/std/language.support/support.types/byteops/lshift.pass.cpp new file mode 100644 index 000000000000..b4a8325199ff --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator <<(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b3{3}; + + static_assert(noexcept(b3 << 2), "" ); + + static_assert(std::to_integer<int>(b1 << 1) == 2, ""); + static_assert(std::to_integer<int>(b1 << 2) == 4, ""); + static_assert(std::to_integer<int>(b3 << 4) == 48, ""); + static_assert(std::to_integer<int>(b3 << 6) == 192, ""); +} diff --git a/test/std/language.support/support.types/byteops/not.pass.cpp b/test/std/language.support/support.types/byteops/not.pass.cpp new file mode 100644 index 000000000000..734780f194a0 --- /dev/null +++ b/test/std/language.support/support.types/byteops/not.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator~(byte b) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2{2}; + constexpr std::byte b8{8}; + + static_assert(noexcept(~b1), "" ); + + static_assert(std::to_integer<int>(~b1) == 254, ""); + static_assert(std::to_integer<int>(~b2) == 253, ""); + static_assert(std::to_integer<int>(~b8) == 247, ""); +} diff --git a/test/std/language.support/support.types/byteops/or.assign.pass.cpp b/test/std/language.support/support.types/byteops/or.assign.pass.cpp new file mode 100644 index 000000000000..75d6ab4d0a9d --- /dev/null +++ b/test/std/language.support/support.types/byteops/or.assign.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte& operator |=(byte l, byte r) noexcept; + + +constexpr std::byte test(std::byte b1, std::byte b2) { + std::byte bret = b1; + return bret |= b2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b1{1}; + constexpr std::byte b2{2}; + constexpr std::byte b8{8}; + + static_assert(noexcept(b |= b), "" ); + + static_assert(std::to_integer<int>(test(b1, b2)) == 3, ""); + static_assert(std::to_integer<int>(test(b1, b8)) == 9, ""); + static_assert(std::to_integer<int>(test(b2, b8)) == 10, ""); + + static_assert(std::to_integer<int>(test(b2, b1)) == 3, ""); + static_assert(std::to_integer<int>(test(b8, b1)) == 9, ""); + static_assert(std::to_integer<int>(test(b8, b2)) == 10, ""); + +} diff --git a/test/std/language.support/support.types/byteops/or.pass.cpp b/test/std/language.support/support.types/byteops/or.pass.cpp new file mode 100644 index 000000000000..02c547f1dbb6 --- /dev/null +++ b/test/std/language.support/support.types/byteops/or.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator|(byte l, byte r) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2{2}; + constexpr std::byte b8{8}; + + static_assert(noexcept(b1 | b2), "" ); + + static_assert(std::to_integer<int>(b1 | b2) == 3, ""); + static_assert(std::to_integer<int>(b1 | b8) == 9, ""); + static_assert(std::to_integer<int>(b2 | b8) == 10, ""); + + static_assert(std::to_integer<int>(b2 | b1) == 3, ""); + static_assert(std::to_integer<int>(b8 | b1) == 9, ""); + static_assert(std::to_integer<int>(b8 | b2) == 10, ""); +} diff --git a/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp b/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp new file mode 100644 index 000000000000..3a0c218aff82 --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator>>(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b >>= 2.0; + } + + +int main () { + constexpr std::byte b1 = test(std::byte{1}); +} diff --git a/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp b/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp new file mode 100644 index 000000000000..5b970258f5e0 --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b >>= 2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b16{16}; + constexpr std::byte b192{192}; + + static_assert(noexcept(b >>= 2), "" ); + + static_assert(std::to_integer<int>(test(b16)) == 4, "" ); + static_assert(std::to_integer<int>(test(b192)) == 48, "" ); +} diff --git a/test/std/language.support/support.types/byteops/rshift.fail.cpp b/test/std/language.support/support.types/byteops/rshift.fail.cpp new file mode 100644 index 000000000000..14e2fcfa1301 --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator >>(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2 = b1 >> 2.0f; +} diff --git a/test/std/language.support/support.types/byteops/rshift.pass.cpp b/test/std/language.support/support.types/byteops/rshift.pass.cpp new file mode 100644 index 000000000000..5ff986a70ade --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator <<(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b <<= 2; + } + + +int main () { + constexpr std::byte b100{100}; + constexpr std::byte b115{115}; + + static_assert(noexcept(b100 << 2), "" ); + + static_assert(std::to_integer<int>(b100 >> 1) == 50, ""); + static_assert(std::to_integer<int>(b100 >> 2) == 25, ""); + static_assert(std::to_integer<int>(b115 >> 3) == 14, ""); + static_assert(std::to_integer<int>(b115 >> 6) == 1, ""); + +} diff --git a/test/std/language.support/support.types/byteops/to_integer.fail.cpp b/test/std/language.support/support.types/byteops/to_integer.fail.cpp new file mode 100644 index 000000000000..8832e506a118 --- /dev/null +++ b/test/std/language.support/support.types/byteops/to_integer.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr IntegerType to_integer(byte b) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + auto f = std::to_integer<float>(b1); +} diff --git a/test/std/language.support/support.types/byteops/to_integer.pass.cpp b/test/std/language.support/support.types/byteops/to_integer.pass.cpp new file mode 100644 index 000000000000..4aca0be82deb --- /dev/null +++ b/test/std/language.support/support.types/byteops/to_integer.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr IntegerType to_integer(byte b) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b3{3}; + + static_assert(noexcept(std::to_integer<int>(b1)), "" ); + static_assert(std::is_same<int, decltype(std::to_integer<int>(b1))>::value, "" ); + static_assert(std::is_same<long, decltype(std::to_integer<long>(b1))>::value, "" ); + static_assert(std::is_same<unsigned short, decltype(std::to_integer<unsigned short>(b1))>::value, "" ); + + static_assert(std::to_integer<int>(b1) == 1, ""); + static_assert(std::to_integer<int>(b3) == 3, ""); +} diff --git a/test/std/language.support/support.types/byteops/xor.assign.pass.cpp b/test/std/language.support/support.types/byteops/xor.assign.pass.cpp new file mode 100644 index 000000000000..c9b40177a17c --- /dev/null +++ b/test/std/language.support/support.types/byteops/xor.assign.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte& operator ^=(byte l, byte r) noexcept; + + +constexpr std::byte test(std::byte b1, std::byte b2) { + std::byte bret = b1; + return bret ^= b2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b ^= b), "" ); + + static_assert(std::to_integer<int>(test(b1, b8)) == 9, ""); + static_assert(std::to_integer<int>(test(b1, b9)) == 8, ""); + static_assert(std::to_integer<int>(test(b8, b9)) == 1, ""); + + static_assert(std::to_integer<int>(test(b8, b1)) == 9, ""); + static_assert(std::to_integer<int>(test(b9, b1)) == 8, ""); + static_assert(std::to_integer<int>(test(b9, b8)) == 1, ""); +} diff --git a/test/std/language.support/support.types/byteops/xor.pass.cpp b/test/std/language.support/support.types/byteops/xor.pass.cpp new file mode 100644 index 000000000000..3d0402b30a55 --- /dev/null +++ b/test/std/language.support/support.types/byteops/xor.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator^(byte l, byte r) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b1 ^ b8), "" ); + + static_assert(std::to_integer<int>(b1 ^ b8) == 9, ""); + static_assert(std::to_integer<int>(b1 ^ b9) == 8, ""); + static_assert(std::to_integer<int>(b8 ^ b9) == 1, ""); + + static_assert(std::to_integer<int>(b8 ^ b1) == 9, ""); + static_assert(std::to_integer<int>(b9 ^ b1) == 8, ""); + static_assert(std::to_integer<int>(b9 ^ b8) == 1, ""); +} diff --git a/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp b/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp index 044ba2b976cb..2e2e97361994 100644 --- a/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp index 4488e9c3f73b..94e45302f10b 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp @@ -15,8 +15,8 @@ // charT tolower(charT) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> #include <cassert> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp index 0c224e342fa9..d97dc5747e54 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp @@ -15,8 +15,8 @@ // const charT* tolower(charT* low, const charT* high) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> #include <string> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp index 0985de5007d6..d2ad328268f1 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp @@ -15,8 +15,8 @@ // charT toupper(charT) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp index ba047754916d..9ed3d138112a 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp @@ -15,8 +15,8 @@ // const charT* toupper(charT* low, const charT* high) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> #include <string> diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp index df350d3537af..1664c5537fa1 100644 --- a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp +++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp @@ -14,7 +14,7 @@ // string_type negative_sign() const; // The C++ and C standards are silent. -// On this one, commen sense is the guideline. +// On this one, common sense is the guideline. // If customers complain, I'll endeavor to minimize customer complaints #include <locale> diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp index 32e7249ab868..72e351f580b4 100644 --- a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp +++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp index 8edcfc415821..4d8c2af38383 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp @@ -38,6 +38,12 @@ int main() char str[50]; output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v); std::string ex(str, iter.base()); - assert(ex == "0x0" || ex == "(nil)"); + char expected_str[32] = {}; + // num_put::put uses %p for pointer types, but the exact format of %p is + // implementation defined behavior for the C library. Compare output to + // snprintf for portability. + int rc = snprintf(expected_str, sizeof(expected_str), "%p", v); + assert(rc > 0); + assert(ex == expected_str); } } diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp index 6d7f506bb2d4..272199b0e0d9 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp index 9a06157ada59..af15b174bcd2 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp @@ -13,7 +13,7 @@ // REQUIRES: locale.zh_CN.UTF-8 // GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009" -// GLIBC also failes on the zh_CN test. +// GLIBC also fails on the zh_CN test. // XFAIL: linux // <locale> diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp index 170f33ad9813..1cd9f462e38e 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp @@ -13,7 +13,7 @@ // REQUIRES: locale.zh_CN.UTF-8 // GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009" -// GLIBC also failes on the zh_CN test. +// GLIBC also fails on the zh_CN test. // XFAIL: linux // <locale> diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp index 4d710c1a9799..56d6262d0692 100644 --- a/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp +++ b/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp @@ -28,11 +28,11 @@ int main() { { - typedef std::codecvt_utf16<wchar_t> C; + typedef std::codecvt_utf16<char32_t> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -67,11 +67,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x1000> C; + typedef std::codecvt_utf16<char32_t, 0x1000> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -106,11 +106,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header> C; + typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp); @@ -145,11 +145,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> C; + typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -184,11 +184,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C; + typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -223,13 +223,13 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode( - std::consume_header | - std::little_endian)> C; + typedef std::codecvt_utf16<char32_t, 0x10ffff, + std::codecvt_mode(std::consume_header | std::little_endian)> C; + C c; - wchar_t w = 0; + char32_t w = 0; char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp); diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp index 382ea122641a..308bb9da2fc1 100644 --- a/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp +++ b/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp @@ -28,11 +28,11 @@ int main() { { - typedef std::codecvt_utf8<wchar_t> C; + typedef std::codecvt_utf8<char32_t> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -67,11 +67,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf8<wchar_t, 0x1000> C; + typedef std::codecvt_utf8<char32_t, 0x1000> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -106,11 +106,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C; + typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+7, np, &w, &w+1, wp); diff --git a/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp index 0087f1943b6e..11346fb402d2 100644 --- a/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp +++ b/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp index 8cc71f7bff27..9e2298cf7718 100644 --- a/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp +++ b/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp @@ -34,7 +34,6 @@ test() void test_edges() { - typedef std::complex<double> C; const unsigned N = sizeof(testcases) / sizeof(testcases[0]); for (unsigned i = 0; i < N; ++i) { diff --git a/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp index 9f09ab5827de..f27ead3daf00 100644 --- a/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp +++ b/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp @@ -35,7 +35,6 @@ test() void test_edges() { - typedef std::complex<double> C; const unsigned N = sizeof(testcases) / sizeof(testcases[0]); for (unsigned i = 0; i < N; ++i) { diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp index d34ff1c64d83..19b74ba28bcd 100644 --- a/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp +++ b/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <valarray> // template<class T> class valarray; @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; T a[] = {1, 2, 3, 4, 5}; @@ -60,5 +61,4 @@ int main() assert(v2[i][j] == a[i][j]); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp index a9692618e75f..b8fb08e0f223 100644 --- a/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp +++ b/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <valarray> // template<class T> class valarray; @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; T a[] = {1, 2, 3, 4, 5}; @@ -58,5 +59,4 @@ int main() assert(v2[i][j] == a[i][j]); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp index 46741e1e41b7..f999c5045a5c 100644 --- a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp +++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp @@ -22,6 +22,7 @@ #include <numeric> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class InIter, class OutIter> @@ -38,7 +39,7 @@ test() assert(ib[i] == ir[i]); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 class Y; @@ -107,7 +108,7 @@ int main() test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 X x[3] = {X(1), X(2), X(3)}; Y y[3] = {Y(1), Y(2), Y(3)}; std::adjacent_difference(x, x+3, y); diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp index fb0bbdc2836d..8a30a82212de 100644 --- a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp +++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp @@ -23,6 +23,7 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class InIter, class OutIter> @@ -40,7 +41,7 @@ test() assert(ib[i] == ir[i]); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 class Y; @@ -110,7 +111,7 @@ int main() test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 X x[3] = {X(1), X(2), X(3)}; Y y[3] = {Y(1), Y(2), Y(3)}; std::adjacent_difference(x, x+3, y, std::minus<X>()); diff --git a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index af065b84d1bb..961b515ef8d8 100644 --- a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 + // <numeric> // template<class _M, class _N> @@ -129,4 +130,11 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2837 + { + auto res = std::gcd((int64_t)1234, (int32_t)-2147483648); + static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res == 2); + } } diff --git a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp index cd03d99ebf13..90d48398f54a 100644 --- a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -128,4 +128,12 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2837 + { + auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648); + (void) std::lcm<int, unsigned long>(INT_MIN, 2); // this used to trigger UBSAN + static_assert( std::is_same<decltype(res1), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res1 == 1324997410816LL); + } } diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp index d70d8f072c39..ca669dc4194a 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp @@ -31,7 +31,6 @@ int main() { { typedef std::cauchy_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; const double a = 10; @@ -47,7 +46,6 @@ int main() } { typedef std::cauchy_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; const double a = -1.5; @@ -63,7 +61,6 @@ int main() } { typedef std::cauchy_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; const double a = .5; diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp index 3b54790aee0a..3261880c6d04 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::chi_squared_distribution<> D; - typedef D::param_type P; typedef std::minstd_rand G; G g; D d(0.5); @@ -74,7 +73,6 @@ int main() } { typedef std::chi_squared_distribution<> D; - typedef D::param_type P; typedef std::minstd_rand G; G g; D d(1); @@ -114,7 +112,6 @@ int main() } { typedef std::chi_squared_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(2); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp index 4da7f2e70e9b..8025880d8754 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp @@ -51,7 +51,6 @@ int main() // Purposefully only testing even integral values of m and n (for now) { typedef std::fisher_f_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(2, 4); @@ -69,7 +68,6 @@ int main() } { typedef std::fisher_f_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(4, 2); @@ -87,7 +85,6 @@ int main() } { typedef std::fisher_f_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(18, 20); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp index e1084d3ef03d..2bf9204d3a09 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::normal_distribution<> D; - typedef D::param_type P; typedef std::minstd_rand G; G g; D d(5, 4); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp index 223d6f4d2216..71aaa081b351 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::exponential_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(.75); @@ -74,7 +73,6 @@ int main() } { typedef std::exponential_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(1); @@ -114,7 +112,6 @@ int main() } { typedef std::exponential_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(10); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp index 10337907b964..ee0b68fb8f9c 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::weibull_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(0.5, 2); @@ -78,7 +77,6 @@ int main() } { typedef std::weibull_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(1, .5); @@ -122,7 +120,6 @@ int main() } { typedef std::weibull_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(2, 3); diff --git a/test/std/re/re.alg/re.alg.match/awk.pass.cpp b/test/std/re/re.alg/re.alg.match/awk.pass.cpp index f866929795db..9bd213f96746 100644 --- a/test/std/re/re.alg/re.alg.match/awk.pass.cpp +++ b/test/std/re/re.alg/re.alg.match/awk.pass.cpp @@ -26,7 +26,8 @@ int main() { -/* { +#if 0 + { std::cmatch m; const char s[] = "a"; assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk))); @@ -263,7 +264,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -278,7 +279,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -293,7 +294,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -326,7 +327,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -341,7 +342,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -356,7 +357,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -378,7 +379,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -394,7 +395,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -410,7 +411,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); assert(m.length(1) == 4); @@ -434,7 +435,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -519,7 +520,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -542,7 +543,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -572,7 +573,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -588,7 +589,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -604,7 +605,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -616,24 +617,23 @@ int main() assert(m.size() == 0); } std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); -*/ { - /* + { std::cmatch m; const char s[] = "m"; - assert(std::regex_match(s, m, std::regex("[a[=M=]z]", - std::regex_constants::awk); - assert(m.size() == 1); + assert(std::regex_match(s, m, + std::regex("[a[=M=]z]", std::regex_constants::awk))); + assert(m.size() == 1); assert(!m.prefix().matched); assert(m.prefix().first == s); assert(m.prefix().second == m[0].first); assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); -*/ } -/* { + } + { std::cmatch m; const char s[] = "Ch"; assert(std::regex_match(s, m, std::regex("[a[.ch.]z]", @@ -645,7 +645,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -688,7 +688,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == 4); + assert((size_t)m.length(0) == 4); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -704,7 +704,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s + std::char_traits<char>::length(s)); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -720,7 +720,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s+1); - assert(m.length(0) == 1); + assert((size_t)m.length(0) == 1); assert(m.position(0) == 0); assert(m.str(0) == L"a"); } @@ -735,7 +735,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s+2); - assert(m.length(0) == 2); + assert((size_t)m.length(0) == 2); assert(m.position(0) == 0); assert(m.str(0) == L"ab"); } @@ -945,7 +945,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -960,7 +960,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -975,7 +975,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1008,7 +1008,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1023,7 +1023,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1038,7 +1038,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1060,7 +1060,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1076,7 +1076,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1092,7 +1092,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); assert(m.length(1) == 4); @@ -1116,7 +1116,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1201,7 +1201,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1224,7 +1224,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1254,7 +1254,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1270,7 +1270,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1286,7 +1286,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1310,7 +1310,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1326,7 +1326,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1385,8 +1385,9 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s)); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } -*/} +#endif +} diff --git a/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp b/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp index 59b2832c4580..d9c5172303fc 100644 --- a/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp +++ b/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp @@ -16,7 +16,7 @@ // const basic_regex<charT, traits>& e, // regex_constants::match_flag_type flags = regex_constants::match_default); -// http://llvm.org/bugs/show_bug.cgi?id=16135 +// https://bugs.llvm.org/show_bug.cgi?id=16135 #include <string> #include <regex> diff --git a/test/std/re/re.alg/re.alg.search/backup.pass.cpp b/test/std/re/re.alg/re.alg.search/backup.pass.cpp index f33b844bed9c..8de0b650ff05 100644 --- a/test/std/re/re.alg/re.alg.search/backup.pass.cpp +++ b/test/std/re/re.alg/re.alg.search/backup.pass.cpp @@ -25,7 +25,7 @@ int main() { // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...) - // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273. + // Test for https://bugs.llvm.org/show_bug.cgi?id=16240 fixed in r185273. { std::string s("aaaa a"); std::regex re("\\ba"); diff --git a/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp b/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp index 93424e188432..2d753ed14701 100644 --- a/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp +++ b/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp @@ -16,7 +16,7 @@ // const basic_regex<charT, traits>& e, // regex_constants::match_flag_type flags = regex_constants::match_default); -// http://llvm.org/bugs/show_bug.cgi?id=11118 +// https://bugs.llvm.org/show_bug.cgi?id=11118 #include <regex> #include <cassert> diff --git a/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp b/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp index aca4d674d9f9..e66d3e976db2 100644 --- a/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp +++ b/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp @@ -36,7 +36,7 @@ int main() assert(error_badbackref_thrown("ab(c)\\2def")); // only one reference // this should NOT throw, because we only should look at the '1' -// See https://llvm.org/bugs/show_bug.cgi?id=31387 +// See https://bugs.llvm.org/show_bug.cgi?id=31387 { const char *pat1 = "a(b)c\\1234"; std::regex re(pat1, pat1 + 7); // extra chars after the end. diff --git a/test/std/re/re.traits/lookup_classname.pass.cpp b/test/std/re/re.traits/lookup_classname.pass.cpp index 4f7cf61ebf99..2215b9043d5b 100644 --- a/test/std/re/re.traits/lookup_classname.pass.cpp +++ b/test/std/re/re.traits/lookup_classname.pass.cpp @@ -35,7 +35,7 @@ test(const char_type* A, int main() { // if __regex_word is not distinct from all the classes, bad things happen -// See https://llvm.org/bugs/show_bug.cgi?id=26476 for an example. +// See https://bugs.llvm.org/show_bug.cgi?id=26476 for an example. assert((std::ctype_base::space & std::regex_traits<char>::__regex_word) == 0); assert((std::ctype_base::print & std::regex_traits<char>::__regex_word) == 0); assert((std::ctype_base::cntrl & std::regex_traits<char>::__regex_word) == 0); diff --git a/test/std/re/re.traits/translate_nocase.pass.cpp b/test/std/re/re.traits/translate_nocase.pass.cpp index bf79629d33b4..ab73db79d97f 100644 --- a/test/std/re/re.traits/translate_nocase.pass.cpp +++ b/test/std/re/re.traits/translate_nocase.pass.cpp @@ -16,8 +16,8 @@ // REQUIRES: locale.en_US.UTF-8 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // TODO: investigation needed // XFAIL: linux-gnu diff --git a/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp b/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp new file mode 100644 index 000000000000..01f01218999d --- /dev/null +++ b/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <string> + +// Test that <string> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <string> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::string>(); + test_hash_enabled_for_type<std::wstring>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test_hash_enabled_for_type<std::u16string>(); + test_hash_enabled_for_type<std::u32string>(); +#endif + } +} diff --git a/test/std/strings/basic.string.hash/strings.pass.cpp b/test/std/strings/basic.string.hash/strings.pass.cpp index 5fc32c06a701..d74e485752fc 100644 --- a/test/std/strings/basic.string.hash/strings.pass.cpp +++ b/test/std/strings/basic.string.hash/strings.pass.cpp @@ -22,6 +22,8 @@ #include <cassert> #include <type_traits> +#include "test_macros.h" + template <class T> void test() @@ -29,6 +31,8 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); + H h; std::string g1 = "1234567890"; std::string g2 = "1234567891"; diff --git a/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp index b3447b94b803..982bb43289d7 100644 --- a/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp @@ -18,6 +18,65 @@ #include "test_allocator.h" #include "min_allocator.h" +#ifndef TEST_HAS_NO_EXCEPTIONS +template <class T> +struct alloc_imp { + bool active; + + alloc_imp() : active(true) {} + + T* allocate(std::size_t n) + { + if (active) + return static_cast<T*>(std::malloc(n * sizeof(T))); + else + throw std::bad_alloc(); + } + + void deallocate(T* p, std::size_t) { std::free(p); } + void activate () { active = true; } + void deactivate() { active = false; } +}; + +template <class T> +struct poca_alloc { + typedef T value_type; + typedef std::true_type propagate_on_container_copy_assignment; + + alloc_imp<T> *imp; + + poca_alloc(alloc_imp<T> *imp_) : imp (imp_) {} + + template <class U> + poca_alloc(const poca_alloc<U>& other) : imp(other.imp) {} + + T* allocate (std::size_t n) { return imp->allocate(n);} + void deallocate(T* p, std::size_t n) { imp->deallocate(p, n); } +}; + +template <typename T, typename U> +bool operator==(const poca_alloc<T>& lhs, const poca_alloc<U>& rhs) +{ + return lhs.imp == rhs.imp; +} + +template <typename T, typename U> +bool operator!=(const poca_alloc<T>& lhs, const poca_alloc<U>& rhs) +{ + return lhs.imp != rhs.imp; +} + +template <class S> +void test_assign(S &s1, const S& s2) +{ + try { s1 = s2; } + catch ( std::bad_alloc &) { return; } + assert(false); +} +#endif + + + template <class S> void test(S s1, const typename S::allocator_type& a) @@ -46,5 +105,27 @@ int main() test(S("1"), A()); test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A()); } + +#ifndef TEST_HAS_NO_EXCEPTIONS + { + typedef poca_alloc<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; + const char * p1 = "This is my first string"; + const char * p2 = "This is my second string"; + + alloc_imp<char> imp1; + alloc_imp<char> imp2; + S s1(p1, A(&imp1)); + S s2(p2, A(&imp2)); + + assert(s1 == p1); + assert(s2 == p2); + + imp2.deactivate(); + test_assign(s1, s2); + assert(s1 == p1); + assert(s2 == p2); + } +#endif #endif } diff --git a/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp index 0c6362d96863..f4ff0645afcf 100644 --- a/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp +++ b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp b/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp new file mode 100644 index 000000000000..0fbd663db4bc --- /dev/null +++ b/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp @@ -0,0 +1,300 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// UNSUPPORTED: libcpp-no-deduction-guides + +// <string> + +// Test that the constructors offered by std::basic_string are formulated +// so they're compatible with implicit deduction guides. + +#include <string> +#include <string_view> +#include <cassert> + +#include "test_macros.h" +#include "test_allocator.h" +#include "test_iterators.h" +#include "constexpr_char_traits.hpp" + +template <class T, class Alloc = std::allocator<T>> +using BStr = std::basic_string<T, std::char_traits<T>, Alloc>; + +// Overloads +// using A = Allocator; +// using BS = basic_string +// using BSV = basic_string_view +// --------------- +// (1) basic_string() - NOT TESTED +// (2) basic_string(A const&) - BROKEN +// (3) basic_string(size_type, CharT, const A& = A()) +// (4) basic_string(BS const&, size_type, A const& = A()) +// (5) basic_string(BS const&, size_type, size_type, A const& = A()) - PARTIALLY BROKEN +// (6) basic_string(const CharT*, size_type, A const& = A()) +// (7) basic_string(const CharT*, A const& = A()) +// (8) basic_string(InputIt, InputIt, A const& = A()) - BROKEN +// (9) basic_string(BS const&) +// (10) basic_string(BS const&, A const&) +// (11) basic_string(BS&&) +// (12) basic_string(BS&&, A const&) +// (13) basic_string(initializer_list<CharT>, A const& = A()) +// (14) basic_string(BSV, A const& = A()) +// (15) basic_string(const T&, size_type, size_type, A const& = A()) - BROKEN +int main() +{ + using TestSizeT = test_allocator<char>::size_type; + { // Testing (1) + // Nothing TODO. Cannot deduce without any arguments. + } + { // Testing (2) + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + // const test_allocator<char> alloc{}; + // std::basic_string s(alloc); + } + { // Testing (3) w/o allocator + std::basic_string s(6ull, 'a'); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "aaaaaa"); + + std::basic_string w(2ull, L'b'); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"bb"); + } + { // Testing (3) w/ allocator + std::basic_string s(6ull, 'a', test_allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), BStr<char,test_allocator<char>>); + assert(s == "aaaaaa"); + + std::basic_string w(2ull, L'b', test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), BStr<wchar_t, test_allocator<wchar_t>>); + assert(w == L"bb"); + } + { // Testing (4) w/o allocator + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)3); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"def"); + } + { // Testing (4) w/ allocator + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)3, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"def"); + } + { // Testing (5) w/o allocator +#if 0 // FIXME: This doesn't work + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1, (size_t)3); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)2, (TestSizeT)3); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"cde"); +#endif + } + { // Testing (5) w/ allocator + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1, (size_t)3, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)2, (TestSizeT)3, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"cde"); + } + { // Testing (6) w/o allocator + std::basic_string s("abc", (size_t)2); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "ab"); + + std::basic_string w(L"abcdef", (size_t)3); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"abc"); + } + { // Testing (6) w/ allocator + std::basic_string s("abc", (size_t)2, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "ab"); + + using WStr = std::basic_string<wchar_t, + std::char_traits<wchar_t>, + test_allocator<wchar_t>>; + std::basic_string w(L"abcdef", (TestSizeT)3, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abc"); + } + { // Testing (7) w/o allocator + std::basic_string s("abc"); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + std::basic_string w(L"abcdef"); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"abcdef"); + } + { // Testing (7) w/ allocator + std::basic_string s("abc", std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + std::char_traits<wchar_t>, + test_allocator<wchar_t>>; + std::basic_string w(L"abcdef", test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // (8) w/o allocator + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + // FIXME: Propose adding an explicit guide to the standard? + } + { // (8) w/ allocator + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + // FIXME: Propose adding an explicit guide to the standard? +#if 0 + using It = input_iterator<const char*>; + const char* input = "abcdef"; + std::basic_string s(It(input), It(input + 3), std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); +#endif + } + { // Testing (9) + const std::string sin("abc"); + std::basic_string s(sin); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (10) + const std::string sin("abc"); + std::basic_string s(sin, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (11) + std::string sin("abc"); + std::basic_string s(std::move(sin)); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + WStr win(L"abcdef"); + std::basic_string w(std::move(win)); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (12) + std::string sin("abc"); + std::basic_string s(std::move(sin), std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + WStr win(L"abcdef"); + std::basic_string w(std::move(win), test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (13) w/o allocator + std::basic_string s({'a', 'b', 'c'}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + std::basic_string w({L'a', L'b', L'c'}); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"abc"); + } + { // Testing (13) w/ allocator + std::basic_string s({'a', 'b', 'c'}, test_allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), BStr<char, test_allocator<char>>); + assert(s == "abc"); + + std::basic_string w({L'a', L'b', L'c'}, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), BStr<wchar_t, test_allocator<wchar_t>>); + assert(w == L"abc"); + } + { // Testing (14) w/o allocator + std::string_view sv("abc"); + std::basic_string s(sv); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using Expect = std::basic_string<wchar_t, constexpr_char_traits<wchar_t>>; + std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>> BSV(L"abcdef"); + std::basic_string w(BSV); + ASSERT_SAME_TYPE(decltype(w), Expect); + assert(w == L"abcdef"); + } + { // Testing (14) w/ allocator + using ExpectS = std::basic_string<char, std::char_traits<char>, test_allocator<char>>; + std::string_view sv("abc"); + std::basic_string s(sv, test_allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), ExpectS); + assert(s == "abc"); + + using ExpectW = std::basic_string<wchar_t, constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>> BSV(L"abcdef"); + std::basic_string w(BSV, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), ExpectW); + assert(w == L"abcdef"); + } + { // Testing (15) + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + } +} diff --git a/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp index 1b10224cd9e7..1f83696891c4 100644 --- a/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp @@ -29,7 +29,6 @@ test(It first, It last) { typedef typename std::iterator_traits<It>::value_type charT; typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S; - typedef typename S::traits_type T; typedef typename S::allocator_type A; S s2(first, last); LIBCPP_ASSERT(s2.__invariants()); @@ -47,7 +46,6 @@ test(It first, It last, const A& a) { typedef typename std::iterator_traits<It>::value_type charT; typedef std::basic_string<charT, std::char_traits<charT>, A> S; - typedef typename S::traits_type T; S s2(first, last, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == static_cast<std::size_t>(std::distance(first, last))); diff --git a/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp index f56780095b7f..d9d451dc7112 100644 --- a/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp @@ -56,7 +56,6 @@ int main() { { typedef test_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(""); test("", A(2)); @@ -73,7 +72,6 @@ int main() #if TEST_STD_VER >= 11 { typedef min_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(""); test("", A()); diff --git a/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp index bcab9eb6789e..3c75a700eaed 100644 --- a/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp @@ -53,7 +53,6 @@ int main() { { typedef test_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test("", 0); test("", 0, A(2)); @@ -70,7 +69,6 @@ int main() #if TEST_STD_VER >= 11 { typedef min_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test("", 0); test("", 0, A()); diff --git a/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp index 60443e9f358d..2adf0049a0b5 100644 --- a/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp @@ -26,7 +26,6 @@ void test(unsigned n, charT c) { typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S; - typedef typename S::traits_type T; typedef typename S::allocator_type A; S s2(n, c); LIBCPP_ASSERT(s2.__invariants()); @@ -42,7 +41,6 @@ void test(unsigned n, charT c, const A& a) { typedef std::basic_string<charT, std::char_traits<charT>, A> S; - typedef typename S::traits_type T; S s2(n, c, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == n); @@ -58,7 +56,6 @@ test(Tp n, Tp c) { typedef char charT; typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S; - typedef typename S::traits_type T; typedef typename S::allocator_type A; S s2(n, c); LIBCPP_ASSERT(s2.__invariants()); @@ -75,7 +72,6 @@ test(Tp n, Tp c, const A& a) { typedef char charT; typedef std::basic_string<charT, std::char_traits<charT>, A> S; - typedef typename S::traits_type T; S s2(n, c, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == static_cast<std::size_t>(n)); @@ -89,7 +85,6 @@ int main() { { typedef test_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(0, 'a'); test(0, 'a', A(2)); @@ -109,7 +104,6 @@ int main() #if TEST_STD_VER >= 11 { typedef min_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(0, 'a'); test(0, 'a', A()); diff --git a/test/std/strings/basic.string/string.cons/substr.pass.cpp b/test/std/strings/basic.string/string.cons/substr.pass.cpp index 4fd974273de9..13a9a4b96aab 100644 --- a/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ b/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -98,7 +98,6 @@ void test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a) { typedef typename S::traits_type T; - typedef typename S::allocator_type A; if (pos <= str.size()) { diff --git a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp index dac8860f9a64..b464291d4c5d 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -204,4 +204,20 @@ int main() assert(s == "ABCD"); } + { // test with a move iterator that returns char&& + typedef forward_iterator<const char*> It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } + { // test with a move iterator that returns char&& + typedef const char* It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp index e5ce8e51e1d6..2c8b6e4a1882 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -188,10 +188,35 @@ int main() { // test assigning a different type typedef std::string S; - const uint8_t p[] = "ABCD"; + const uint8_t p[] = "ABCD"; - S s; - s.insert(s.begin(), p, p + 4); - assert(s == "ABCD"); + S s; + s.insert(s.begin(), p, p + 4); + assert(s == "ABCD"); } + + { // test with a move iterator that returns char&& + typedef input_iterator<const char*> It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } + { // test with a move iterator that returns char&& + typedef forward_iterator<const char*> It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } + { // test with a move iterator that returns char&& + typedef const char* It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp index 840b7614f482..dbf5f5b64446 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp @@ -29,16 +29,22 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, SV sv, typename S::size_type pos2, typename S::size_type n2, S expected) { + typedef typename S::size_type SizeT; static_assert((!std::is_same<S, SV>::value), ""); - const typename S::size_type old_size = s.size(); + + // String and string_view may not always share the same size type, + // but both types should have the same size (ex. int vs long) + static_assert(sizeof(SizeT) == sizeof(typename SV::size_type), ""); + + const SizeT old_size = s.size(); S s0 = s; if (pos1 <= old_size && pos2 <= sv.size()) { s.replace(pos1, n1, sv, pos2, n2); LIBCPP_ASSERT(s.__invariants()); assert(s == expected); - typename S::size_type xlen = std::min(n1, old_size - pos1); - typename S::size_type rlen = std::min(n2, sv.size() - pos2); + SizeT xlen = std::min<SizeT>(n1, old_size - pos1); + SizeT rlen = std::min<SizeT>(n2, sv.size() - pos2); assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS @@ -64,16 +70,17 @@ test_npos(S s, typename S::size_type pos1, typename S::size_type n1, SV sv, typename S::size_type pos2, S expected) { + typedef typename S::size_type SizeT; static_assert((!std::is_same<S, SV>::value), ""); - const typename S::size_type old_size = s.size(); + const SizeT old_size = s.size(); S s0 = s; if (pos1 <= old_size && pos2 <= sv.size()) { s.replace(pos1, n1, sv, pos2); LIBCPP_ASSERT(s.__invariants()); assert(s == expected); - typename S::size_type xlen = std::min(n1, old_size - pos1); - typename S::size_type rlen = std::min(S::npos, sv.size() - pos2); + SizeT xlen = std::min<SizeT>(n1, old_size - pos1); + SizeT rlen = std::min<SizeT>(S::npos, sv.size() - pos2); assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS diff --git a/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp index 757d5eeb2dc3..88c1bee32512 100644 --- a/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp +++ b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp @@ -59,10 +59,12 @@ int main() typedef std::string C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/strings/basic.string/traits_mismatch.fail.cpp b/test/std/strings/basic.string/traits_mismatch.fail.cpp new file mode 100644 index 000000000000..1d54238ae0c0 --- /dev/null +++ b/test/std/strings/basic.string/traits_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> +// The strings's value type must be the same as the traits's char_type + +#include <string> + +int main() +{ + std::basic_string<char, std::char_traits<wchar_t>> s; +} diff --git a/test/std/strings/string.classes/typedefs.pass.cpp b/test/std/strings/string.classes/typedefs.pass.cpp index 11ee6c8a1215..3aba1c3f15dd 100644 --- a/test/std/strings/string.classes/typedefs.pass.cpp +++ b/test/std/strings/string.classes/typedefs.pass.cpp @@ -18,13 +18,14 @@ // typedef basic_string<wchar_t> wstring; #include <string> +#include <type_traits> int main() { - typedef std::string test1; - typedef std::wstring test2; + static_assert((std::is_same<std::string, std::basic_string<char> >::value), ""); + static_assert((std::is_same<std::wstring, std::basic_string<wchar_t> >::value), ""); #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - typedef std::u16string test3; - typedef std::u32string test4; + static_assert((std::is_same<std::u16string, std::basic_string<char16_t> >::value), ""); + static_assert((std::is_same<std::u32string, std::basic_string<char32_t> >::value), ""); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/string.conversions/stof.pass.cpp b/test/std/strings/string.conversions/stof.pass.cpp index 1e17e1d3abdd..aeef0ddfbc78 100644 --- a/test/std/strings/string.conversions/stof.pass.cpp +++ b/test/std/strings/string.conversions/stof.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stol.pass.cpp b/test/std/strings/string.conversions/stol.pass.cpp index 457cf0a76997..f01bbf8ce29e 100644 --- a/test/std/strings/string.conversions/stol.pass.cpp +++ b/test/std/strings/string.conversions/stol.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stoll.pass.cpp b/test/std/strings/string.conversions/stoll.pass.cpp index ca8412aeb758..b823ab742626 100644 --- a/test/std/strings/string.conversions/stoll.pass.cpp +++ b/test/std/strings/string.conversions/stoll.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stoul.pass.cpp b/test/std/strings/string.conversions/stoul.pass.cpp index 1acdf116458f..5e1f696cb6b7 100644 --- a/test/std/strings/string.conversions/stoul.pass.cpp +++ b/test/std/strings/string.conversions/stoul.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stoull.pass.cpp b/test/std/strings/string.conversions/stoull.pass.cpp index e63679eed2f4..70563d9be51f 100644 --- a/test/std/strings/string.conversions/stoull.pass.cpp +++ b/test/std/strings/string.conversions/stoull.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.view/string.view.access/at.pass.cpp b/test/std/strings/string.view/string.view.access/at.pass.cpp index 0f1636d3f94f..6df879898f44 100644 --- a/test/std/strings/string.view/string.view.access/at.pass.cpp +++ b/test/std/strings/string.view/string.view.access/at.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// NOTE: Older versions of clang have a bug where they fail to evalute +// NOTE: Older versions of clang have a bug where they fail to evaluate // string_view::at as a constant expression. // XFAIL: clang-3.4, clang-3.3 diff --git a/test/std/strings/string.view/string.view.cons/assign.pass.cpp b/test/std/strings/string.view/string.view.cons/assign.pass.cpp new file mode 100644 index 000000000000..b7348ea226cf --- /dev/null +++ b/test/std/strings/string.view/string.view.cons/assign.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +// <string_view> + +// constexpr basic_string_view& operator=(const basic_string_view &) noexcept = default; + +#include <string_view> +#include <cassert> + +#include "test_macros.h" + +template<typename T> +#if TEST_STD_VER > 11 +constexpr +#endif +bool test (T sv0) + { + T sv1; + sv1 = sv0; +// We can't just say "sv0 == sv1" here because string_view::compare +// isn't constexpr until C++17, and we want to support back to C++14 + return sv0.size() == sv1.size() && sv0.data() == sv1.data(); + } + +int main () { + + assert( test<std::string_view> ( "1234")); +#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS + assert( test<std::u16string_view> (u"1234")); + assert( test<std::u32string_view> (U"1234")); +#endif + assert( test<std::wstring_view> (L"1234")); + +#if TEST_STD_VER > 11 + static_assert( test<std::string_view> ({ "abc", 3}), ""); +#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert( test<std::u16string_view> ({u"abc", 3}), ""); + static_assert( test<std::u32string_view> ({U"abc", 3}), ""); +#endif + static_assert( test<std::wstring_view> ({L"abc", 3}), ""); +#endif +} diff --git a/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp b/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp new file mode 100644 index 000000000000..7dd99d9c4405 --- /dev/null +++ b/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// UNSUPPORTED: libcpp-no-deduction-guides + +// <string_view> + +// Test that the constructors offered by std::basic_string_view are formulated +// so they're compatible with implicit deduction guides. + +#include <string_view> +#include <cassert> + +#include "test_macros.h" +#include "constexpr_char_traits.hpp" + +// Overloads +// --------------- +// (1) basic_string_view() - NOT TESTED +// (2) basic_string_view(const basic_string_view&) +// (3) basic_string_view(const CharT*, size_type) +// (4) basic_string_view(const CharT*) +int main() +{ + { // Testing (1) + // Nothing TODO. Cannot deduce without any arguments. + } + { // Testing (2) + const std::string_view sin("abc"); + std::basic_string_view s(sin); + ASSERT_SAME_TYPE(decltype(s), std::string_view); + assert(s == "abc"); + + using WSV = std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>>; + const WSV win(L"abcdef"); + std::basic_string_view w(win); + ASSERT_SAME_TYPE(decltype(w), WSV); + assert(w == L"abcdef"); + } + { // Testing (3) + std::basic_string_view s("abc", 2); + ASSERT_SAME_TYPE(decltype(s), std::string_view); + assert(s == "ab"); + + std::basic_string_view w(L"abcdef", 4); + ASSERT_SAME_TYPE(decltype(w), std::wstring_view); + assert(w == L"abcd"); + } + { // Testing (4) + std::basic_string_view s("abc"); + ASSERT_SAME_TYPE(decltype(s), std::string_view); + assert(s == "abc"); + + std::basic_string_view w(L"abcdef"); + ASSERT_SAME_TYPE(decltype(w), std::wstring_view); + assert(w == L"abcdef"); + } +} diff --git a/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp b/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp new file mode 100644 index 000000000000..2e9ebcb4c037 --- /dev/null +++ b/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <string_view> + +// Test that <string_view> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <string_view> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::string_view>(); + test_hash_enabled_for_type<std::wstring_view>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test_hash_enabled_for_type<std::u16string_view>(); + test_hash_enabled_for_type<std::u32string_view>(); +#endif + } +} diff --git a/test/std/strings/string.view/string.view.hash/string_view.pass.cpp b/test/std/strings/string.view/string.view.hash/string_view.pass.cpp index 63099e2c8864..53c3d261d882 100644 --- a/test/std/strings/string.view/string.view.hash/string_view.pass.cpp +++ b/test/std/strings/string.view/string.view.hash/string_view.pass.cpp @@ -19,29 +19,41 @@ // Not very portable #include <string_view> +#include <string> #include <cassert> #include <type_traits> +#include "test_macros.h" + using std::string_view; -template <class T> +template <class SV> void test() { - typedef std::hash<T> H; - static_assert((std::is_same<typename H::argument_type, T>::value), "" ); + typedef std::hash<SV> H; + static_assert((std::is_same<typename H::argument_type, SV>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); - H h; -// std::string g1 = "1234567890"; -// std::string g2 = "1234567891"; - typedef typename T::value_type char_type; + + typedef typename SV::value_type char_type; + typedef std::basic_string<char_type> String; + typedef std::hash<String> SH; + ASSERT_NOEXCEPT(H()(SV())); + char_type g1 [ 10 ]; char_type g2 [ 10 ]; for ( int i = 0; i < 10; ++i ) g1[i] = g2[9-i] = static_cast<char_type>('0' + i); - T s1(g1, 10); - T s2(g2, 10); + H h; + SH sh; + SV s1(g1, 10); + String ss1(s1); + SV s2(g2, 10); + String ss2(s2); + assert(h(s1) == h(s1)); assert(h(s1) != h(s2)); + assert(sh(ss1) == h(s1)); + assert(sh(ss2) == h(s2)); } int main() diff --git a/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp b/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp index 381f792e5ce0..16a4da882739 100644 --- a/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp +++ b/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp @@ -58,4 +58,23 @@ int main() test(u16string_view{u"123"}); test(u32string_view{U"123"}); #endif + +#if TEST_STD_VER > 14 + { + constexpr string_view sv { "123", 3 }; + constexpr u16string_view u16sv {u"123", 3 }; + constexpr u32string_view u32sv {U"123", 3 }; + constexpr wstring_view wsv {L"123", 3 }; + + static_assert ( *sv.rbegin() == sv[2], "" ); + static_assert ( *u16sv.rbegin() == u16sv[2], "" ); + static_assert ( *u32sv.rbegin() == u32sv[2], "" ); + static_assert ( *wsv.rbegin() == wsv[2], "" ); + + static_assert ( *sv.crbegin() == sv[2], "" ); + static_assert ( *u16sv.crbegin() == u16sv[2], "" ); + static_assert ( *u32sv.crbegin() == u32sv[2], "" ); + static_assert ( *wsv.crbegin() == wsv[2], "" ); + } +#endif } diff --git a/test/std/strings/string.view/string.view.iterators/rend.pass.cpp b/test/std/strings/string.view/string.view.iterators/rend.pass.cpp index ca529fb708dc..08f9e5a7755b 100644 --- a/test/std/strings/string.view/string.view.iterators/rend.pass.cpp +++ b/test/std/strings/string.view/string.view.iterators/rend.pass.cpp @@ -66,4 +66,23 @@ int main() test(u16string_view{u"123"}); test(u32string_view{U"123"}); #endif + +#if TEST_STD_VER > 14 + { + constexpr string_view sv { "123", 3 }; + constexpr u16string_view u16sv {u"123", 3 }; + constexpr u32string_view u32sv {U"123", 3 }; + constexpr wstring_view wsv {L"123", 3 }; + + static_assert ( *--sv.rend() == sv[0], "" ); + static_assert ( *--u16sv.rend() == u16sv[0], "" ); + static_assert ( *--u32sv.rend() == u32sv[0], "" ); + static_assert ( *--wsv.rend() == wsv[0], "" ); + + static_assert ( *--sv.crend() == sv[0], "" ); + static_assert ( *--u16sv.crend() == u16sv[0], "" ); + static_assert ( *--u32sv.crend() == u32sv[0], "" ); + static_assert ( *--wsv.crend() == wsv[0], "" ); + } +#endif } diff --git a/test/std/strings/string.view/string_view.literals/literal.pass.cpp b/test/std/strings/string.view/string_view.literals/literal.pass.cpp index 9fb128ab0f55..710009cc51ee 100644 --- a/test/std/strings/string.view/string_view.literals/literal.pass.cpp +++ b/test/std/strings/string.view/string_view.literals/literal.pass.cpp @@ -48,7 +48,7 @@ int main() Lfoo = L"ABC"sv; assert(Lfoo == L"ABC"); assert(Lfoo == std::wstring_view ( L"ABC")); ufoo = u"ABC"sv; assert(ufoo == u"ABC"); assert(ufoo == std::u16string_view( u"ABC")); Ufoo = U"ABC"sv; assert(Ufoo == U"ABC"); assert(Ufoo == std::u32string_view( U"ABC")); - + static_assert( "ABC"sv.size() == 3, ""); static_assert(u8"ABC"sv.size() == 3, ""); static_assert( L"ABC"sv.size() == 3, ""); diff --git a/test/std/strings/string.view/nothing_to_do.pass.cpp b/test/std/strings/string.view/traits_mismatch.fail.cpp index 353dd98f415e..6cd15e6a67ba 100644 --- a/test/std/strings/string.view/nothing_to_do.pass.cpp +++ b/test/std/strings/string.view/traits_mismatch.fail.cpp @@ -7,6 +7,12 @@ // //===----------------------------------------------------------------------===// +// <string_view> +// The string_views's value type must be the same as the traits's char_type + #include <string_view> -int main () {} +int main() +{ + std::basic_string_view<char, std::char_traits<wchar_t>> s; +} diff --git a/test/std/thread/futures/futures.future_error/what.pass.cpp b/test/std/thread/futures/futures.future_error/what.pass.cpp index a44f8af7d41b..cc2d978d2c2b 100644 --- a/test/std/thread/futures/futures.future_error/what.pass.cpp +++ b/test/std/thread/futures/futures.future_error/what.pass.cpp @@ -12,8 +12,8 @@ // LWG 2056 changed the values of future_errc, so if we're using new headers // with an old library we'll get incorrect messages. // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin13 // <future> diff --git a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp index e0c6e15d98d5..e986885c0c71 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp @@ -6,7 +6,8 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// + +// UNSUPPORTED: c++98, c++03 // UNSUPPORTED: libcpp-has-no-threads, libcpp-no-exceptions // <future> @@ -19,8 +20,6 @@ #include <memory> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - struct A { A() {} @@ -28,11 +27,8 @@ struct A A(A&&) {throw 9;} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unique_ptr<int> T; T i(new int(3)); @@ -65,5 +61,4 @@ int main() assert(j == 9); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp index 8f3b76865e2a..05675725bf43 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -19,23 +19,17 @@ #include <memory> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - void func(std::promise<std::unique_ptr<int>> p) { p.set_value_at_thread_exit(std::unique_ptr<int>(new int(5))); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::promise<std::unique_ptr<int>> p; std::future<std::unique_ptr<int>> f = p.get_future(); std::thread(func, std::move(p)).detach(); assert(*f.get() == 5); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp index 39784876b8c3..7cac21d48aef 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp @@ -69,7 +69,7 @@ int main() p(3, 'a'); assert(f.get() == 105.0); assert(A::n_copies > 0); - assert(A::n_moves > 0); + assert(A::n_moves >= 0); } assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; diff --git a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp index 8d38b81f0cda..4a790b06cfdf 100644 --- a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -20,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise<T> p; @@ -72,5 +71,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp index e12c920886fa..14e2eb416961 100644 --- a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -20,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise<T> p; @@ -66,5 +65,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.unique_future/share.pass.cpp b/test/std/thread/futures/futures.unique_future/share.pass.cpp index ef011d8df752..9b8667e538cc 100644 --- a/test/std/thread/futures/futures.unique_future/share.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -25,14 +25,16 @@ int main() typedef int T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } @@ -40,14 +42,16 @@ int main() typedef int& T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int& T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } @@ -55,14 +59,16 @@ int main() typedef void T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef void T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } diff --git a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp index d60e42918860..de225fe78384 100644 --- a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp +++ b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// REQUIRES: libcpp-has-thread-api-pthread // notify_all_at_thread_exit(...) requires move semantics to transfer the // unique_lock. diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp index a2b7061c2546..71cbc94a70a4 100644 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -24,8 +24,8 @@ // ----------------------------------------------------------------------------- // Overview -// Check that std::terminate is called if wait(...) fails to meet it's post -// conditions. This can happens when reacquiring the mutex throws +// Check that std::terminate is called if wait(...) fails to meet its post +// conditions. This can happen when reacquiring the mutex throws // an exception. // // The following methods are tested within this file @@ -37,7 +37,7 @@ // 6. void wait_until(Lock& lock, TimePoint, Pred); // // Plan -// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is aquired +// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is acquired // for the *second* time. // // 2 Replace the terminate handler with one that exits with a '0' exit code. diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index 46d04cdac350..245c480885b8 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -9,10 +9,10 @@ // // UNSUPPORTED: libcpp-has-no-threads -// This test hangs forever when built against libstdc++. In order to allow +// This test hangs forever when built against libstdc++ and MSVC. In order to allow // validation of the test suite against other STLs we have to mark it // unsupported. -// UNSUPPORTED: libstdc++ +// UNSUPPORTED: libstdc++, msvc // <mutex> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp index a15405fcd98b..fffd087ee877 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp @@ -15,11 +15,16 @@ // explicit lock_guard(mutex_type& m); +// template<class _Mutex> lock_guard(lock_guard<_Mutex>) +// -> lock_guard<_Mutex>; // C++17 + #include <mutex> #include <thread> #include <cstdlib> #include <cassert> +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -47,4 +52,9 @@ int main() std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); + +#ifdef __cpp_deduction_guides + std::lock_guard lg(m); + static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp deleted file mode 100644 index 0ad16e2856fd..000000000000 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// <mutex> - -// template <class ...Mutex> class lock_guard; - -// Test that the variadic lock guard implementation compiles in all standard -// dialects, including C++03, even though it is forward declared using -// variadic templates. - -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#include "mutex.pass.cpp" // Use the existing non-variadic test diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp index 81fc0d368f6a..78165383a158 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp @@ -8,18 +8,17 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard(Mutex&..., adopt_lock_t); +// scoped_lock(Mutex&..., adopt_lock_t); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> +#include "test_macros.h" struct TestMutex { bool locked = false; @@ -36,12 +35,22 @@ struct TestMutex { int main() { { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg(std::adopt_lock); } { + TestMutex m1; + using LG = std::scoped_lock<TestMutex>; + m1.lock(); + { + LG lg(m1, std::adopt_lock); + assert(m1.locked); + } + assert(!m1.locked); + } + { TestMutex m1, m2; - using LG = std::lock_guard<TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex>; m1.lock(); m2.lock(); { LG lg(m1, m2, std::adopt_lock); @@ -51,7 +60,7 @@ int main() } { TestMutex m1, m2, m3; - using LG = std::lock_guard<TestMutex, TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex, TestMutex>; m1.lock(); m2.lock(); m3.lock(); { LG lg(m1, m2, m3, std::adopt_lock); diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp index 1b4c9d4bfd5d..a05472935526 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp @@ -8,17 +8,16 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard& operator=(lock_guard const&) = delete; +// scoped_lock& operator=(scoped_lock const&) = delete; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" int main() { @@ -26,18 +25,24 @@ int main() M m0, m1, m2; M om0, om1, om2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg1, lg2; lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + LG lg1(m0); + LG lg2(om0); + lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} + } + { + using LG = std::scoped_lock<M, M>; LG lg1(m0, m1); LG lg2(om0, om1); lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; LG lg1(m0, m1, m2); LG lg2(om0, om1, om2); lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp index c7fd0e94b771..5075a4268095 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp @@ -8,34 +8,38 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard(lock_guard const&) = delete; +// scoped_lock(scoped_lock const&) = delete; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" int main() { using M = std::mutex; M m0, m1, m2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; const LG Orig; LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + const LG Orig(m0); + LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} + } + { + using LG = std::scoped_lock<M, M>; const LG Orig(m0, m1); LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; const LG Orig(m0, m1, m2); LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp index 1eef7e268fb2..7bb4673265cf 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp @@ -8,17 +8,16 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// explicit lock_guard(Mutex&...); +// explicit scoped_lock(Mutex&...); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" template <class LG> void test_conversion(LG) {} @@ -29,19 +28,25 @@ int main() M m0, m1, m2; M n0, n1, n2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({}); // expected-error{{no matching function for call}} ((void)lg); } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + LG lg = {m0}; // expected-error{{chosen constructor is explicit in copy-initialization}} + test_conversion<LG>({n0}); // expected-error{{no matching function for call}} + ((void)lg); + } + { + using LG = std::scoped_lock<M, M>; LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}} ((void)lg); } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}} } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp index 8d83ddf98c6d..ef39bbcc5e88 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp @@ -8,19 +8,16 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// explicit lock_guard(mutex_type& m); +// explicit scoped_lock(mutex_type& m); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> - #include "test_macros.h" struct TestMutex { @@ -68,11 +65,20 @@ struct TestMutexThrows { int main() { { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg; } { - using LG = std::lock_guard<TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex>; + TestMutex m1; + { + LG lg(m1); + assert(m1.locked); + } + assert(!m1.locked); + } + { + using LG = std::scoped_lock<TestMutex, TestMutex>; TestMutex m1, m2; { LG lg(m1, m2); @@ -81,7 +87,7 @@ int main() assert(!m1.locked && !m2.locked); } { - using LG = std::lock_guard<TestMutex, TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex, TestMutex>; TestMutex m1, m2, m3; { LG lg(m1, m2, m3); @@ -92,7 +98,18 @@ int main() #if !defined(TEST_HAS_NO_EXCEPTIONS) { using MT = TestMutexThrows; - using LG = std::lock_guard<MT, MT>; + using LG = std::scoped_lock<MT>; + MT m1; + m1.throws_on_lock = true; + try { + LG lg(m1); + assert(false); + } catch (int) {} + assert(!m1.locked); + } + { + using MT = TestMutexThrows; + using LG = std::scoped_lock<MT, MT>; MT m1, m2; m1.throws_on_lock = true; try { @@ -103,7 +120,7 @@ int main() } { using MT = TestMutexThrows; - using LG = std::lock_guard<MT, MT, MT>; + using LG = std::scoped_lock<MT, MT, MT>; MT m1, m2, m3; m2.throws_on_lock = true; try { @@ -113,4 +130,26 @@ int main() assert(!m1.locked && !m2.locked && !m3.locked); } #endif + +#ifdef __cpp_deduction_guides + { + TestMutex m1, m2, m3; + { + std::scoped_lock sl{}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<>>::value), "" ); + } + { + std::scoped_lock sl{m1}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1)>>::value), "" ); + } + { + std::scoped_lock sl{m1, m2}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1), decltype(m2)>>::value), "" ); + } + { + std::scoped_lock sl{m1, m2, m3}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1), decltype(m2), decltype(m3)>>::value), "" ); + } + } +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp index 600399d9793e..6af3c6c952d7 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp @@ -8,22 +8,21 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class Mutex> -// class lock_guard +// template <class Mutex...> +// class scoped_lock // { // public: -// typedef Mutex mutex_type; +// typedef Mutex mutex_type; // only if sizeof...(Mutex) == 1 // ... // }; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <type_traits> +#include "test_macros.h" struct NAT {}; @@ -41,39 +40,39 @@ constexpr bool has_mutex_type() { int main() { { - using T = std::lock_guard<>; + using T = std::scoped_lock<>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; - using T = std::lock_guard<M1>; + using T = std::scoped_lock<M1>; static_assert(std::is_same<T::mutex_type, M1>::value, ""); } { using M1 = std::recursive_mutex; - using T = std::lock_guard<M1>; + using T = std::scoped_lock<M1>; static_assert(std::is_same<T::mutex_type, M1>::value, ""); } { using M1 = std::mutex; using M2 = std::recursive_mutex; - using T = std::lock_guard<M1, M2>; + using T = std::scoped_lock<M1, M2>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; using M2 = std::recursive_mutex; - using T = std::lock_guard<M1, M1, M2>; + using T = std::scoped_lock<M1, M1, M2>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; - using T = std::lock_guard<M1, M1>; + using T = std::scoped_lock<M1, M1>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::recursive_mutex; - using T = std::lock_guard<M1, M1, M1>; + using T = std::scoped_lock<M1, M1, M1>; static_assert(!has_mutex_type<T>(), ""); } } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp index f9a537085c30..ac338064d1fd 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp @@ -18,6 +18,9 @@ // explicit shared_lock(mutex_type& m); +// template<class _Mutex> shared_lock(shared_lock<_Mutex>) +// -> shared_lock<_Mutex>; // C++17 + #include <shared_mutex> #include <thread> #include <vector> @@ -92,4 +95,9 @@ int main() t.join(); q.join(); } + +#ifdef __cpp_deduction_guides + std::shared_lock sl(m); + static_assert((std::is_same<decltype(sl), std::shared_lock<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp index e5db685e46e7..6f17383298fd 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <mutex> @@ -21,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::mutex M; M m0; @@ -46,5 +45,4 @@ int main() assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp index 427deabc5a59..04aa79673431 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <mutex> @@ -21,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::mutex M; M m; @@ -42,5 +41,4 @@ int main() assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp index 1f7217a8300e..ca8bc6982253 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp @@ -15,11 +15,16 @@ // explicit unique_lock(mutex_type& m); +// template<class _Mutex> unique_lock(unique_lock<_Mutex>) +// -> unique_lock<_Mutex>; // C++17 + #include <mutex> #include <thread> #include <cstdlib> #include <cassert> +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -47,4 +52,9 @@ int main() std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); + +#ifdef __cpp_deduction_guides + std::unique_lock ul(m); + static_assert((std::is_same<decltype(ul), std::unique_lock<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp index 2db9430a698d..d3478818c056 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <thread> @@ -44,7 +44,6 @@ bool G::op_run = false; int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { assert(G::n_alive == 0); assert(!G::op_run); @@ -61,5 +60,4 @@ int main() assert(G::n_alive == 0); assert(G::op_run); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp index 437b42037913..d419b8cc855c 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp @@ -106,7 +106,7 @@ public: // A Each allocation performed during thread construction should be performed // in the parent thread so that std::terminate is not called if // std::bad_alloc is thrown by new. -// B std::threads constructor should properly handle exceptions and not leak +// B std::thread's constructor should properly handle exceptions and not leak // memory. // Plan: // 1 Create a thread and count the number of allocations, 'N', it performs. diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp index e88304ec8da9..f349e4c56fcb 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <thread> @@ -53,7 +53,6 @@ bool G::op_run = false; int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { G g; assert(G::n_alive == 1); @@ -68,5 +67,4 @@ int main() assert(G::op_run); } assert(G::n_alive == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp new file mode 100644 index 000000000000..9799467c4529 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <thread> + +// Test that <thread> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <thread> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::thread::id>(); + } +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp index 106c69e2e4a1..4f1491decd31 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp @@ -9,7 +9,7 @@ // // UNSUPPORTED: libcpp-has-no-threads -// <functional> +// <thread> // template <class T> // struct hash @@ -23,6 +23,8 @@ #include <thread> #include <cassert> +#include "test_macros.h" + int main() { std::thread::id id1; @@ -30,6 +32,7 @@ int main() typedef std::hash<std::thread::id> H; static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(id2)); H h; assert(h(id1) != h(id2)); } diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp index ef3b9302c7a2..dfb187b6cc2d 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp @@ -87,7 +87,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp index 6f31d264280a..9689fb014786 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp @@ -88,7 +88,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp index a761b3288060..92df0f6f2264 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp @@ -87,7 +87,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp index de33eeb2fbda..2b7fe3f641ae 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp @@ -83,7 +83,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp index 867cc74082e7..8568c7380b6d 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp @@ -31,7 +31,6 @@ // OUTERMOST_ALLOC_TRAITS(*this)::construct( // OUTERMOST (*this), p, std::forward<Args>(args)...). void test_bullet_one() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; @@ -41,7 +40,6 @@ void test_bullet_one() { using Outer = CountingAllocator<T, 1>; using Inner = CountingAllocator<T, 2>; using SA = std::scoped_allocator_adaptor<Outer, Inner>; - using SAInner = std::scoped_allocator_adaptor<Inner>; static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(!std::uses_allocator<T, Inner>::value, ""); T* ptr = (T*)::operator new(sizeof(T)); @@ -66,7 +64,6 @@ void test_bullet_one() { // true, calls OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST (*this), p, // allocator_arg, inner_allocator(), std::forward<Args>(args)...). void test_bullet_two() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; @@ -76,7 +73,6 @@ void test_bullet_two() { using Outer = CountingAllocator<T, 1>; using Inner = CountingAllocator<T, 2>; using SA = std::scoped_allocator_adaptor<Outer, Inner>; - using SAInner = std::scoped_allocator_adaptor<Inner>; static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); T* ptr = (T*)::operator new(sizeof(T)); @@ -101,7 +97,6 @@ void test_bullet_two() { // OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST (*this), p, // std::forward<Args>(args)..., inner_allocator()). void test_bullet_three() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; @@ -111,7 +106,6 @@ void test_bullet_three() { using Outer = CountingAllocator<T, 1>; using Inner = CountingAllocator<T, 2>; using SA = std::scoped_allocator_adaptor<Outer, Inner>; - using SAInner = std::scoped_allocator_adaptor<Inner>; static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); T* ptr = (T*)::operator new(sizeof(T)); diff --git a/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp b/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp index 65d94fd1e0a4..75dfb0a2e704 100644 --- a/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp +++ b/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp @@ -11,9 +11,9 @@ // <any> -// template <class T, class ...Args> emplace(Args&&...); +// template <class T, class ...Args> T& emplace(Args&&...); // template <class T, class U, class ...Args> -// void emplace(initializer_list<U>, Args&&...); +// T& emplace(initializer_list<U>, Args&&...); #include <any> #include <cassert> @@ -42,7 +42,9 @@ void test_emplace_type() { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(); + auto &v = a.emplace<Type>(); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -56,7 +58,9 @@ void test_emplace_type() { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(101); + auto &v = a.emplace<Type>(101); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -70,7 +74,9 @@ void test_emplace_type() { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(-1, 42, -1); + auto &v = a.emplace<Type>(-1, 42, -1); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -89,14 +95,20 @@ void test_emplace_type_tracked() { { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(); + auto &v = a.emplace<Type>(); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type>(a); } { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(-1, 42, -1); + auto &v = a.emplace<Type>(-1, 42, -1); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type, int, int, int>(a); } @@ -104,7 +116,10 @@ void test_emplace_type_tracked() { { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>({-1, 42, -1}); + auto &v = a.emplace<Type>({-1, 42, -1}); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type, std::initializer_list<int>>(a); } @@ -112,7 +127,10 @@ void test_emplace_type_tracked() { int x = 42; any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>({-1, 42, -1}, x); + auto &v = a.emplace<Type>({-1, 42, -1}, x); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type, std::initializer_list<int>, int&>(a); } diff --git a/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp b/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp index 99cc029971a8..bbc135051ef8 100644 --- a/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp +++ b/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp @@ -25,13 +25,30 @@ using std::any_cast; int main() { any a(1); - any_cast<int &>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int &&>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const &>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const&&>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &>(&a); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &&>(&a); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const &>(&a); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const&&>(&a); // expected-note {{requested here}} + any const& a2 = a; - any_cast<int &>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int &&>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const &>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const &&>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &>(&a2); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &&>(&a2); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const &>(&a2); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const &&>(&a2); // expected-note {{requested here}} } diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp index 5e347c4c5715..943e162172b0 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// https://llvm.org/bugs/show_bug.cgi?id=23141 +// https://bugs.llvm.org/show_bug.cgi?id=23141 #include <functional> #include <type_traits> diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp index ad03e8fb6bb2..a4d502bb800e 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// http://llvm.org/bugs/show_bug.cgi?id=16385 +// https://bugs.llvm.org/show_bug.cgi?id=16385 #include <functional> #include <cmath> diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp index 180433109f26..a9a38b83cb4e 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// http://llvm.org/bugs/show_bug.cgi?id=22003 +// https://bugs.llvm.org/show_bug.cgi?id=22003 #include <functional> diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp index 0d4244b4d860..5b660da617a8 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// http://llvm.org/bugs/show_bug.cgi?id=16343 +// https://bugs.llvm.org/show_bug.cgi?id=16343 #include <cmath> #include <functional> diff --git a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp index 47a3e1cc5969..2b19211be9bf 100644 --- a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp +++ b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp @@ -414,7 +414,14 @@ void throws_in_constructor_test() throw 42; } ThrowsOnCopy() = default; - bool operator()() const { assert(false); } + bool operator()() const { + assert(false); +#if defined(_LIBCPP_MSVC) + __assume(0); +#else + __builtin_unreachable(); +#endif + } }; { ThrowsOnCopy cp; diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp index 5bdf9e98e897..812f6fc502d9 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp @@ -8,11 +8,11 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 -// REQUIRES-ANY: c++11, c++14 +// REQUIRES: c++11 || c++14 // <functional> -// See https://llvm.org/bugs/show_bug.cgi?id=20002 +// See https://bugs.llvm.org/show_bug.cgi?id=20002 #include <functional> #include <type_traits> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp index f89bde8e6544..3affd984af60 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp @@ -14,7 +14,7 @@ // function(Fp); // Ensure that __not_null works for all function types. -// See https://llvm.org/bugs/show_bug.cgi?id=23589 +// See https://bugs.llvm.org/show_bug.cgi?id=23589 //------------------------------------------------------------------------------ // TESTING std::function<...>::__not_null(Callable) @@ -31,7 +31,7 @@ // types can be null. The other categories are not tested here. // 3) '__not_null(Callable)' is well formed when the call signature includes // varargs. -// 4) '__not_null(Callable)' works for Callable types with all aritys less +// 4) '__not_null(Callable)' works for Callable types with all arities less // than or equal to 3 in C++03. // 5) '__not_null(Callable)' works when 'Callable' is a member function // pointer to a cv or ref qualified function type. diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp index 392dfc1993bc..adc7856357e7 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 || c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp index 8d454723320c..4c1a1ca95ff4 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 ||c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp index 718aa49341d2..8b0e831287a5 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 || c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp index 354ad955f207..943e170878f2 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 || c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp index e328481b274d..3e5435da1a16 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 -// REQUIRES-ANY: c++11, c++14 +// REQUIRES: c++11 || c++14 // <functional> diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp index 74d24fd488b6..775247fc80b6 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp +++ b/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// -// <memory> +// UNSUPPORTED: c++98, c++03 -// unique_ptr +// <functional> -// Test unique_ptr default ctor +// Test that <functional> provides all of the arithmetic, enum, and pointer +// hash specializations. -// default unique_ptr ctor should require non-pointer Deleter +#include <functional> -#include <memory> +#include "poisoned_hash_helper.hpp" -int main() -{ - std::unique_ptr<int[], void (*)(void*)> p; +int main() { + test_library_hash_specializations_available(); } diff --git a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp index af367789a105..a7ddd9a49997 100644 --- a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp @@ -36,6 +36,7 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); typedef typename std::underlying_type<T>::type under_type; H h1; @@ -43,7 +44,8 @@ test() for (int i = 0; i <= 5; ++i) { T t(static_cast<T> (i)); - if (sizeof(T) <= sizeof(std::size_t)) + const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings + if (small) assert(h1(t) == h2(static_cast<under_type>(i))); } } diff --git a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp index 643e2d8c5d86..e67aa016c1e7 100644 --- a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp @@ -24,6 +24,8 @@ #include <limits> #include <cmath> +#include "test_macros.h" + template <class T> void test() @@ -31,6 +33,7 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; std::size_t t0 = h(0.); diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp index 2f3f9bee4bc3..ce87f5918b20 100644 --- a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp @@ -31,12 +31,14 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; for (int i = 0; i <= 5; ++i) { T t(static_cast<T>(i)); - if (sizeof(T) <= sizeof(std::size_t)) + const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings + if (small) { const std::size_t result = h(t); LIBCPP_ASSERT(result == static_cast<size_t>(t)); @@ -63,42 +65,42 @@ int main() test<long long>(); test<unsigned long long>(); -// LWG #2119 +// LWG #2119 test<std::ptrdiff_t>(); test<size_t>(); - test<int8_t>(); - test<int16_t>(); - test<int32_t>(); - test<int64_t>(); + test<int8_t>(); + test<int16_t>(); + test<int32_t>(); + test<int64_t>(); - test<int_fast8_t>(); - test<int_fast16_t>(); - test<int_fast32_t>(); - test<int_fast64_t>(); + test<int_fast8_t>(); + test<int_fast16_t>(); + test<int_fast32_t>(); + test<int_fast64_t>(); - test<int_least8_t>(); - test<int_least16_t>(); - test<int_least32_t>(); - test<int_least64_t>(); + test<int_least8_t>(); + test<int_least16_t>(); + test<int_least32_t>(); + test<int_least64_t>(); test<intmax_t>(); test<intptr_t>(); - test<uint8_t>(); - test<uint16_t>(); - test<uint32_t>(); - test<uint64_t>(); + test<uint8_t>(); + test<uint16_t>(); + test<uint32_t>(); + test<uint64_t>(); - test<uint_fast8_t>(); - test<uint_fast16_t>(); - test<uint_fast32_t>(); - test<uint_fast64_t>(); + test<uint_fast8_t>(); + test<uint_fast16_t>(); + test<uint_fast32_t>(); + test<uint_fast64_t>(); - test<uint_least8_t>(); - test<uint_least16_t>(); - test<uint_least32_t>(); - test<uint_least64_t>(); + test<uint_least8_t>(); + test<uint_least16_t>(); + test<uint_least32_t>(); + test<uint_least64_t>(); test<uintmax_t>(); test<uintptr_t>(); diff --git a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp index a48394495e2d..36280a38e0a7 100644 --- a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp @@ -23,6 +23,8 @@ #include <type_traits> #include <limits> +#include "test_macros.h" + template <class T> void test() @@ -30,6 +32,7 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; typedef typename std::remove_pointer<T>::type type; @@ -38,7 +41,20 @@ test() assert(h(&i) != h(&j)); } +// can't hash nullptr_t until c++17 +void test_nullptr() +{ +#if TEST_STD_VER > 14 + typedef std::nullptr_t T; + typedef std::hash<T> H; + static_assert((std::is_same<typename H::argument_type, T>::value), "" ); + static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); +#endif +} + int main() { test<int*>(); + test_nullptr(); } diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp index 533d516707e1..05e55e3d9a4e 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp @@ -80,7 +80,7 @@ void test_counted() Counted* p = (Counted*)pool; std::uninitialized_default_construct(It(p), It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); std::uninitialized_default_construct(It(p+1), It(p+N)); assert(Counted::count == 5); assert(Counted::constructed == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp index f22a74f1f832..e5b9eca439cf 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp @@ -80,7 +80,7 @@ void test_counted() It e = std::uninitialized_default_construct_n(It(p), 1); assert(e == It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); e = std::uninitialized_default_construct_n(It(p+1), 4); assert(e == It(p+N)); assert(Counted::count == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp index c2d860694a75..8479ce123a78 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp @@ -79,7 +79,7 @@ void test_counted() Counted* p = (Counted*)pool; std::uninitialized_value_construct(It(p), It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); std::uninitialized_value_construct(It(p+1), It(p+N)); assert(Counted::count == 5); assert(Counted::constructed == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp index 323d00f7c9c4..ad6a51500e36 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp @@ -81,7 +81,7 @@ void test_counted() It e = std::uninitialized_value_construct_n(It(p), 1); assert(e == It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); e = std::uninitialized_value_construct_n(It(p+1), 4); assert(e == It(p+N)); assert(Counted::count == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp index d7a9542b4c27..6c535250fd1f 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp @@ -88,7 +88,7 @@ void test_counted() Counted* p = (Counted*)pool; auto ret = std::uninitialized_move(It(values), It(values + 1), FIt(p)); assert(ret == FIt(p +1)); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); assert(Counted::count == 1); assert(p[0].value == 1); assert(values[0] == 0); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp index f27e5726135f..4175c6bce688 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp @@ -89,7 +89,7 @@ void test_counted() auto ret = std::uninitialized_move_n(It(values), 1, FIt(p)); assert(ret.first == It(values +1)); assert(ret.second == FIt(p +1)); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); assert(Counted::count == 1); assert(p[0].value == 1); assert(values[0] == 0); diff --git a/test/std/utilities/memory/unique.ptr/deleter.h b/test/std/utilities/memory/unique.ptr/deleter.h deleted file mode 100644 index 1d8e19d5bc41..000000000000 --- a/test/std/utilities/memory/unique.ptr/deleter.h +++ /dev/null @@ -1,338 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Example move-only deleter - -#ifndef DELETER_H -#define DELETER_H - -#include <type_traits> -#include <utility> -#include <cassert> - -#include "test_macros.h" - -#if TEST_STD_VER >= 11 - -template <class T> -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); - -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - - Deleter() : state_(0) {} - explicit Deleter(int s) : state_(s) {} - ~Deleter() {assert(state_ >= 0); state_ = -1;} - - template <class U> - Deleter(Deleter<U>&& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template <class U> - Deleter(const Deleter<U>& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -template <class T> -class Deleter<T[]> -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); - -public: - - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(0) {} - explicit Deleter(int s) : state_(s) {} - ~Deleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - -#else // TEST_STD_VER < 11 - -template <class T> -class Deleter -{ - mutable int state_; - -public: - Deleter() : state_(0) {} - explicit Deleter(int s) : state_(s) {} - - Deleter(Deleter const & other) : state_(other.state_) { - other.state_ = 0; - } - Deleter& operator=(Deleter const& other) { - state_ = other.state_; - other.state_ = 0; - return *this; - } - - ~Deleter() {assert(state_ >= 0); state_ = -1;} - - template <class U> - Deleter(Deleter<U> d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) - : state_(d.state()) {} - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -template <class T> -class Deleter<T[]> -{ - mutable int state_; - -public: - - Deleter(Deleter const& other) : state_(other.state_) { - other.state_ = 0; - } - Deleter& operator=(Deleter const& other) { - state_ = other.state_; - other.state_ = 0; - return *this; - } - - Deleter() : state_(0) {} - explicit Deleter(int s) : state_(s) {} - ~Deleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - -#endif - -template <class T> -void -swap(Deleter<T>& x, Deleter<T>& y) -{ - Deleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - - -template <class T> -class CDeleter -{ - int state_; - -public: - - CDeleter() : state_(0) {} - explicit CDeleter(int s) : state_(s) {} - ~CDeleter() {assert(state_ >= 0); state_ = -1;} - - template <class U> - CDeleter(const CDeleter<U>& d) - : state_(d.state()) {} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -template <class T> -class CDeleter<T[]> -{ - int state_; - -public: - - CDeleter() : state_(0) {} - explicit CDeleter(int s) : state_(s) {} - ~CDeleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - -template <class T> -void -swap(CDeleter<T>& x, CDeleter<T>& y) -{ - CDeleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - -// Non-copyable deleter -template <class T> -class NCDeleter -{ - int state_; - NCDeleter(NCDeleter const&); - NCDeleter& operator=(NCDeleter const&); -public: - - NCDeleter() : state_(0) {} - explicit NCDeleter(int s) : state_(s) {} - ~NCDeleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - - -template <class T> -class NCDeleter<T[]> -{ - int state_; - NCDeleter(NCDeleter const&); - NCDeleter& operator=(NCDeleter const&); -public: - - NCDeleter() : state_(0) {} - explicit NCDeleter(int s) : state_(s) {} - ~NCDeleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - - -// Non-copyable deleter -template <class T> -class NCConstDeleter -{ - int state_; - NCConstDeleter(NCConstDeleter const&); - NCConstDeleter& operator=(NCConstDeleter const&); -public: - - NCConstDeleter() : state_(0) {} - explicit NCConstDeleter(int s) : state_(s) {} - ~NCConstDeleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) const {delete p;} -}; - - -template <class T> -class NCConstDeleter<T[]> -{ - int state_; - NCConstDeleter(NCConstDeleter const&); - NCConstDeleter& operator=(NCConstDeleter const&); -public: - - NCConstDeleter() : state_(0) {} - explicit NCConstDeleter(int s) : state_(s) {} - ~NCConstDeleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) const {delete [] p;} -}; - - -// Non-copyable deleter -template <class T> -class CopyDeleter -{ - int state_; -public: - - CopyDeleter() : state_(0) {} - explicit CopyDeleter(int s) : state_(s) {} - ~CopyDeleter() {assert(state_ >= 0); state_ = -1;} - - CopyDeleter(CopyDeleter const& other) : state_(other.state_) {} - CopyDeleter& operator=(CopyDeleter const& other) { - state_ = other.state_; - return *this; - } - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - - -template <class T> -class CopyDeleter<T[]> -{ - int state_; - -public: - - CopyDeleter() : state_(0) {} - explicit CopyDeleter(int s) : state_(s) {} - ~CopyDeleter() {assert(state_ >= 0); state_ = -1;} - - CopyDeleter(CopyDeleter const& other) : state_(other.state_) {} - CopyDeleter& operator=(CopyDeleter const& other) { - state_ = other.state_; - return *this; - } - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - - -#endif // DELETER_H diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp deleted file mode 100644 index 286e6bc9a7b9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -// test move assignment. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s1(new A[3]); - A* p = s1.get(); - assert(A::count == 3); - std::unique_ptr<A[]> s2(new A[2]); - assert(A::count == 5); - s2 = std::move(s1); - assert(A::count == 3); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5)); - A* p = s1.get(); - assert(A::count == 4); - std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]); - assert(A::count == 9); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 4); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter<A[]> d1(5); - std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1); - A* p = s1.get(); - assert(A::count == 6); - CDeleter<A[]> d2(6); - std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2); - assert(A::count == 9); - s2 = std::move(s1); - assert(A::count == 6); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp deleted file mode 100644 index 3712a2796392..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <utility> -#include <cassert> - -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp deleted file mode 100644 index 4e85e5b0fb90..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp deleted file mode 100644 index 9461958a431d..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -// Can't assign from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp deleted file mode 100644 index 1737136f4d72..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp deleted file mode 100644 index 3c89bb12344e..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp deleted file mode 100644 index 970beb5a150e..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -// Can't assign from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const boost::unique_ptr<B[]> s(new B); - A* p = s.get(); - boost::unique_ptr<A[]> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp deleted file mode 100644 index 786858dd4016..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp deleted file mode 100644 index 46d4c0985d71..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - const boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp deleted file mode 100644 index 65ee2694156f..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[]> s(new B); - A* p = s.get(); - boost::unique_ptr<A[]> s2(new A); - assert(A::count == 2); - s2 = boost::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp deleted file mode 100644 index da08195ffdd3..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = (boost::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp deleted file mode 100644 index aeec076cb86a..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// test converting move assignment with reference deleters - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = boost::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp deleted file mode 100644 index e2d7956cda64..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = 0; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp deleted file mode 100644 index 50389978e8ab..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// The deleter is not called if get() == 0 - -#include <memory> -#include <cassert> - -#include "test_macros.h" - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(0) {} - - int state() const {return state_;} - - void operator()(void*) {++state_;} -}; - -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr<int[], Deleter&> p(nullptr, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } -#if defined(_LIBCPP_VERSION) - { - // The standard only requires the constructor accept nullptr, but libc++ - // also supports the literal 0. - std::unique_ptr<int[], Deleter&> p(0, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } -#endif - assert(d.state() == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp deleted file mode 100644 index 30ecdded3cf7..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s2(new A[3]); - assert(A::count == 3); - s2 = nullptr; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp deleted file mode 100644 index e7ad6ad7ef33..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>::pointer type - -#include <memory> -#include <type_traits> - -struct Deleter -{ - struct pointer {}; -}; - -int main() -{ - { - typedef std::unique_ptr<int[]> P; - static_assert((std::is_same<P::pointer, int*>::value), ""); - } - { - typedef std::unique_ptr<int[], Deleter> P; - static_assert((std::is_same<P::pointer, Deleter::pointer>::value), ""); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp deleted file mode 100644 index b6bcad9a91c6..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require default Deleter ctor - - -#include <memory> - -class Deleter -{ - // expected-error@memory:* {{base class 'Deleter' has private default constructor}} - // expected-note@memory:* + {{in instantiation of member function}} - Deleter() {} // expected-note {{implicitly declared private here}} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) { return *this; } - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp deleted file mode 100644 index 0cc54382b98d..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should only require default Deleter ctor - -#include <memory> -#include <cassert> - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int[]> p; - assert(p.get() == 0); - } - { - std::unique_ptr<int[], Deleter> p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp deleted file mode 100644 index 3ded41c419c8..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test default unique_ptr<T[]> ctor - -// default unique_ptr<T[]> ctor shouldn't require complete type - -#include <memory> -#include <cassert> - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A> > -struct B -{ - std::unique_ptr<A[], D> a_; - B(); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -int main() -{ - { - B<> s; - assert(s.get() == 0); - } - check(0); - { - B<Deleter> s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B() {} - -template <class D> -B<D>::~B() {} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp deleted file mode 100644 index bc49a0e5c31e..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp deleted file mode 100644 index 5088a4410e79..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - } - assert(A::count == 0); - { - std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5)); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - NCDeleter<A[]> d; - std::unique_ptr<A[], NCDeleter<A[]>&> s(new A[3], d); - A* p = s.get(); - std::unique_ptr<A[], NCDeleter<A[]>&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp deleted file mode 100644 index 8e44c78bf1e9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp deleted file mode 100644 index 89b6fa248845..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - - -std::unique_ptr<A[]> -source1() -{ - return std::unique_ptr<A[]>(new A[3]); -} - -void sink1(std::unique_ptr<A[]>) -{ -} - -std::unique_ptr<A[], Deleter<A[]> > -source2() -{ - return std::unique_ptr<A[], Deleter<A[]> >(new A[3]); -} - -void sink2(std::unique_ptr<A[], Deleter<A[]> >) -{ -} - -std::unique_ptr<A[], NCDeleter<A[]>&> -source3() -{ - static NCDeleter<A[]> d; - return std::unique_ptr<A[], NCDeleter<A[]>&>(new A[3], d); -} - -void sink3(std::unique_ptr<A[], NCDeleter<A[]>&>) -{ -} - -int main() -{ - sink1(source1()); - sink2(source2()); - sink3(source3()); - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp deleted file mode 100644 index c952cf2d4e13..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - std::unique_ptr<A[], Deleter> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[], Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp deleted file mode 100644 index 0d091ff346d1..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - const std::unique_ptr<A[], Deleter> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[], Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp deleted file mode 100644 index d175fbf93adc..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp deleted file mode 100644 index 1838511b4929..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp deleted file mode 100644 index 36ad75d8331a..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp deleted file mode 100644 index 3a19bde92889..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp deleted file mode 100644 index bda2a70a4ef3..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp deleted file mode 100644 index fba895137b05..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp deleted file mode 100644 index 24c646988f0a..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp deleted file mode 100644 index 486d90825d9e..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp deleted file mode 100644 index e4cbef5c0560..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp deleted file mode 100644 index 73423d1b3751..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp deleted file mode 100644 index cfc097ba0b84..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp deleted file mode 100644 index fdb088250b9f..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp deleted file mode 100644 index d9ef8e96fe8f..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp deleted file mode 100644 index b4577a126c68..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp deleted file mode 100644 index 9325d07d0d0c..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp deleted file mode 100644 index b090e593ec62..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp deleted file mode 100644 index b2af3c7a6938..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp deleted file mode 100644 index d1c0e8a781e6..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp deleted file mode 100644 index 9a8c17547bca..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int[]> p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr<int[], Deleter> p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp deleted file mode 100644 index 4c3161150831..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor - -#include <memory> - -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp deleted file mode 100644 index dab42f277411..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[]> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp deleted file mode 100644 index 1afb1c32ce8c..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor shouldn't require complete type - -#include <memory> -#include <cassert> - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A[]> > -struct B -{ - std::unique_ptr<A[], D> a_; - explicit B(A*); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -A* get(); - -int main() -{ - { - A* p = get(); - check(3); - B<> s(p); - assert(s.get() == p); - } - check(0); - { - A* p = get(); - check(3); - B<Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -A* get() {return new A[3];} - -void Deleter::operator()(A* p) {delete [] p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B(A* a) : a_(a) {} - -template <class D> -B<D>::~B() {} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp deleted file mode 100644 index 591144f7aa58..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should not work with derived pointers - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - B* p = new B[3]; - std::unique_ptr<A[]> s(p); - } - { - B* p = new B[3]; - std::unique_ptr<A[], Deleter> s(p); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp deleted file mode 100644 index 3de556563f97..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>()); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - - { // LWG#2520 says that nullptr is a valid input as well as null -#ifdef _LIBCPP_VERSION - std::unique_ptr<A[], Deleter<A[]> > s1(NULL, Deleter<A[]>()); -#endif - std::unique_ptr<A[], Deleter<A[]> > s2(nullptr, Deleter<A[]>()); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp deleted file mode 100644 index a92fdbc1d2c4..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, d) requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], Deleter> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr<A[], Deleter> s(nullptr, d); - assert(s.get() == nullptr); - assert(s.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp deleted file mode 100644 index dd27401731a6..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr<A[], Deleter&> s(nullptr, d); - assert(s.get() == nullptr); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp deleted file mode 100644 index 9d3f94098a08..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// XFAIL: c++98, c++03 - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T, const D&>(pointer, D()) should not compile - -#include <memory> - -class Deleter -{ -public: - Deleter() {} - void operator()(int* p) const {delete [] p;} -}; - -int main() -{ - int* p = nullptr; - std::unique_ptr<int[], const Deleter&> s(p, Deleter()); // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp deleted file mode 100644 index 02f44d357561..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], const Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr<A[], const Deleter&> s(nullptr, d); - assert(s.get() == nullptr); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp deleted file mode 100644 index 0e03a7da07fb..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter) should not work with derived pointers - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - B* p = new B[3]; - std::unique_ptr<A[], Deleter> s(p, Deleter()); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp deleted file mode 100644 index d79a4e396eed..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test release - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int[]> p(new int[3]); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete [] j; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp deleted file mode 100644 index 195d877bbb70..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> p(new A[3]); - assert(A::count == 3); - A* i = p.get(); - assert(i != nullptr); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A[]> p(new A[4]); - assert(A::count == 4); - A* i = p.get(); - assert(i != nullptr); - p.reset(new A[5]); - assert(A::count == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp deleted file mode 100644 index bca6cb2470ac..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> p(new A); - assert(A::count == 1); - assert(B::count == 0); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - std::unique_ptr<A[]> p(new B); - assert(A::count == 1); - assert(B::count == 1); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp deleted file mode 100644 index e9754cc0f226..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test swap - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - int state_; - static int count; - A() : state_(0) {++count;} - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1)); - A* p2 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2)); - assert(s1.get() == p1); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(s2.get_deleter().state() == 1); - assert(A::count == 6); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp deleted file mode 100644 index 46ba1395bb85..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op*() - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int[]> p(new int(3)); - assert(*p == 3); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp deleted file mode 100644 index 4496740715a5..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get_deleter() - -#include <memory> -#include <cassert> - -struct Deleter -{ - void operator()(void*) {} - - int test() {return 5;} - int test() const {return 6;} -}; - -int main() -{ - { - std::unique_ptr<int[], Deleter> p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr<int[], Deleter> p; - assert(p.get_deleter().test() == 6); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp deleted file mode 100644 index 519eae688ec1..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op[](size_t) - -#include <memory> -#include <cassert> - -class A -{ - int state_; - static int next_; -public: - A() : state_(++next_) {} - int get() const {return state_;} - - friend bool operator==(const A& x, int y) - {return x.state_ == y;} - - A& operator=(int i) {state_ = i; return *this;} -}; - -int A::next_ = 0; - -int main() -{ - std::unique_ptr<A[]> p(new A[3]); - assert(p[0] == 1); - assert(p[1] == 2); - assert(p[2] == 3); - p[0] = 3; - p[1] = 2; - p[2] = 1; - assert(p[0] == 3); - assert(p[1] == 2); - assert(p[2] == 1); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp deleted file mode 100644 index 380f2e100eb6..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr::pointer type - -#include <memory> -#include <type_traits> - -#include "test_macros.h" - -struct Deleter -{ - struct pointer {}; -}; - -struct D2 { -private: - typedef void pointer; -}; - -struct D3 { - static long pointer; -}; - -int main() -{ - { - typedef std::unique_ptr<int> P; - static_assert((std::is_same<P::pointer, int*>::value), ""); - } - { - typedef std::unique_ptr<int, Deleter> P; - static_assert((std::is_same<P::pointer, Deleter::pointer>::value), ""); - } -#if TEST_STD_VER >= 11 - { - typedef std::unique_ptr<int, D2> P; - static_assert(std::is_same<P::pointer, int*>::value, ""); - } - { - typedef std::unique_ptr<int, D3> P; - static_assert(std::is_same<P::pointer, int*>::value, ""); - } -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp deleted file mode 100644 index 87cfb72ad6e0..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -// Can't copy from lvalue -int main() -{ - std::unique_ptr<int> s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp deleted file mode 100644 index 9535ed0295d4..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -// test move assignment. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s1(new A); - A* p = s1.get(); - std::unique_ptr<A> s2(new A); - assert(A::count == 2); - s2 = std::move(s1); - assert(A::count == 1); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5)); - A* p = s1.get(); - std::unique_ptr<A, Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter<A> d1(5); - std::unique_ptr<A, CDeleter<A>&> s1(new A, d1); - A* p = s1.get(); - CDeleter<A> d2(6); - std::unique_ptr<A, CDeleter<A>&> s2(new A, d2); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 1); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp deleted file mode 100644 index 9cea12b1249f..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -// Can't copy from const lvalue - -int main() -{ - const std::unique_ptr<int> s(new int); - std::unique_ptr<int> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp deleted file mode 100644 index 05a057f9bb32..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -struct Deleter { - void operator()(int* p) {delete p;} -}; - -// Can't copy from lvalue -int main() -{ - std::unique_ptr<int, Deleter> s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp deleted file mode 100644 index 24703ec98238..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -struct Deleter { - void operator()(int* p) {delete p;} -}; - -// Can't copy from a const lvalue -int main() -{ - const std::unique_ptr<int, Deleter> s(new int); - std::unique_ptr<int, Deleter> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp deleted file mode 100644 index 4c4a32035641..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - - -template <class APtr, class BPtr> -void testAssign(APtr& aptr, BPtr& bptr) { - A* p = bptr.get(); - assert(A::count == 2); - aptr = std::move(bptr); - assert(aptr.get() == p); - assert(bptr.get() == 0); - assert(A::count == 1); - assert(B::count == 1); -} - -template <class LHS, class RHS> -void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { - assert(lhs.get_deleter().state() == LHSState); - assert(rhs.get_deleter().state() == RHSState); -} - -int main() -{ - { - std::unique_ptr<B> bptr(new B); - std::unique_ptr<A> aptr(new A); - testAssign(aptr, bptr); - } - assert(A::count == 0); - assert(B::count == 0); - { - Deleter<B> del(42); - std::unique_ptr<B, Deleter<B> > bptr(new B, std::move(del)); - std::unique_ptr<A, Deleter<A> > aptr(new A); - testAssign(aptr, bptr); - checkDeleter(aptr, bptr, 42, 0); - } - assert(A::count == 0); - assert(B::count == 0); - { - CDeleter<A> adel(6); - CDeleter<B> bdel(42); - std::unique_ptr<B, CDeleter<B>&> bptr(new B, bdel); - std::unique_ptr<A, CDeleter<A>&> aptr(new A, adel); - testAssign(aptr, bptr); - checkDeleter(aptr, bptr, 42, 42); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp deleted file mode 100644 index 816a598d9a23..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> - -#include "test_macros.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - std::unique_ptr<B> s; - std::unique_ptr<A> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp deleted file mode 100644 index 1ddf1d811651..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> - -#include "test_macros.h" -#include "../../deleter.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - std::unique_ptr<B, Deleter<B> > s; - std::unique_ptr<A, Deleter<A> > s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp deleted file mode 100644 index 570c1c42f4fe..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> - -#include "test_macros.h" -#include "../../deleter.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - Deleter<B> db; - std::unique_ptr<B, Deleter<B>& > s(new B, db); - Deleter<A> da; - std::unique_ptr<A, Deleter<A> &> s2(new A, da); -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp deleted file mode 100644 index 2ebc33d21d81..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> - -#include "test_macros.h" -#include "../../deleter.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - const std::unique_ptr<B> s(new B); - std::unique_ptr<A> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp deleted file mode 100644 index 4694986c6773..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B, Deleter<B> > s(new B); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp deleted file mode 100644 index 220677cd6fa7..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - const std::unique_ptr<B, Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - std::unique_ptr<A, Deleter<A>&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp deleted file mode 100644 index 412648420d46..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Do not convert from an array unique_ptr - -#include <memory> -#include <utility> -#include <cassert> - -struct A -{ -}; - -struct Deleter -{ - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<A[], Deleter> s; - std::unique_ptr<A, Deleter> s2; - s2 = std::move(s); // expected-error {{no viable overloaded '='}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp deleted file mode 100644 index 7c3ac462c287..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// libc++ cannot safely provide the auto_ptr constructor without rvalue -// references. -// XFAIL: c++98, c++03 - -// <memory> - -// unique_ptr - -// template <class U> unique_ptr(auto_ptr<U>&&) noexcept - -#include <memory> -#include <utility> -#include <cassert> - -#include "test_macros.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up(std::move(ap)); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up; - up = std::move(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -#if TEST_STD_VER >= 11 - { - static_assert(std::is_nothrow_constructible< - std::unique_ptr<A>, - std::auto_ptr<B>&& - >::value, ""); - } -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp deleted file mode 100644 index 1f317c782454..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B -// : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up; - up = ap; - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp deleted file mode 100644 index 2dd5ea30049b..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct Deleter -{ - template <class T> - void operator()(T*) {} -}; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A, Deleter> up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp deleted file mode 100644 index 2694538145b9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -//============================================================================= -// TESTING std::unique_ptr::unique_ptr() -// -// Concerns: -// 1 The default constructor works for any default constructible deleter types. -// 2 The stored type 'T' is allowed to be incomplete. -// -// Plan -// 1 Default construct unique_ptr's with various deleter types (C-1) -// 2 Default construct a unique_ptr with a incomplete element_type and -// various deleter types (C-1,2) - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct IncompleteT; - -void checkNumIncompleteTypeAlive(int i); - -template <class Del = std::default_delete<IncompleteT> > -struct StoresIncomplete { - std::unique_ptr<IncompleteT, Del> m_ptr; - StoresIncomplete() {} - ~StoresIncomplete(); - - IncompleteT* get() const { return m_ptr.get(); } - Del& get_deleter() { return m_ptr.get_deleter(); } -}; - -int main() -{ - { - std::unique_ptr<int> p; - assert(p.get() == 0); - } - { - std::unique_ptr<int, NCDeleter<int> > p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 0); - p.get_deleter().set_state(5); - assert(p.get_deleter().state() == 5); - } - { - StoresIncomplete<> s; - assert(s.get() == 0); - checkNumIncompleteTypeAlive(0); - } - checkNumIncompleteTypeAlive(0); - { - StoresIncomplete< Deleter<IncompleteT> > s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 0); - checkNumIncompleteTypeAlive(0); - } - checkNumIncompleteTypeAlive(0); -} - -struct IncompleteT { - static int count; - IncompleteT() { ++count; } - ~IncompleteT() {--count; } -}; - -int IncompleteT::count = 0; - -void checkNumIncompleteTypeAlive(int i) { - assert(IncompleteT::count == i); -} - -template <class Del> -StoresIncomplete<Del>::~StoresIncomplete() { }
\ No newline at end of file diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp deleted file mode 100644 index 2ffe1be190e0..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int, Deleter> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp deleted file mode 100644 index 690750143414..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int, Deleter&> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp deleted file mode 100644 index 78f6e73a1d55..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr<int, void (*)(void*)> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp deleted file mode 100644 index 4c5cc843a138..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -//============================================================================= -// TESTING unique_ptr(unique_ptr&&) -// -// Concerns -// 1 The moved from pointer is empty and the new pointer stores the old value. -// 2 The only requirement on the deleter is that it is MoveConstructible -// or a reference. -// 3 The constructor works for explicitly moved values (ie std::move(x)) -// 4 The constructor works for true temporaries (ie a return value) -// -// Plan -// 1 Explicitly construct unique_ptr<T, D> for various deleter types 'D'. -// check that the value and deleter have been properly moved. (C-1,2,3) -// -// 2 Use the expression 'sink(source())' to move construct a unique_ptr<T, D> -// from a temporary. 'source' should return the unique_ptr by value and -// 'sink' should accept the unique_ptr by value. (C-1,2,4) - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -template <class Expect> -void sinkFunction(Expect) -{ -} - -typedef std::unique_ptr<A> APtrSource1; -typedef std::unique_ptr<A, Deleter<A> > APtrSource2; -typedef std::unique_ptr<A, NCDeleter<A>& > APtrSource3; - -APtrSource1 source1() { - return APtrSource1 (new A); -} - -void sink1(APtrSource1 p) { - assert(p.get() != nullptr); -} - -APtrSource2 source2() { - return APtrSource2(new A, Deleter<A>(5)); -} - -void sink2(APtrSource2 p) { - assert(p.get() != nullptr); - assert(p.get_deleter().state() == 5); -} - -APtrSource3 source3() { - static NCDeleter<A> d(5); - return APtrSource3(new A, d); -} - -void sink3(APtrSource3 p) { - assert(p.get() != nullptr); - assert(p.get_deleter().state() == 5); - assert(&p.get_deleter() == &source3().get_deleter()); -} - -int main() -{ - { - typedef std::unique_ptr<A> APtr; - APtr s(new A); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); - { - typedef Deleter<A> MoveDel; - typedef std::unique_ptr<A, MoveDel> APtr; - MoveDel d(5); - APtr s(new A, std::move(d)); - assert(d.state() == 0); - assert(s.get_deleter().state() == 5); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - typedef NCDeleter<A> NonCopyDel; - typedef std::unique_ptr<A, NonCopyDel&> APtr; - - NonCopyDel d; - APtr s(new A, d); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - { - sink1(source1()); - assert(A::count == 0); - sink2(source2()); - assert(A::count == 0); - sink3(source3()); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp deleted file mode 100644 index 68ad589b1148..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp deleted file mode 100644 index 897b889d6778..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp deleted file mode 100644 index 7fb1a0a74811..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp deleted file mode 100644 index 671e343fd7f5..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp deleted file mode 100644 index f00fcfe15b80..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp +++ /dev/null @@ -1,171 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// - -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// NOTE: unique_ptr does not provide converting constructors in c++03 -// XFAIL: c++98, c++03 - - - -#include <memory> -#include <type_traits> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - - -template <class LHS, class RHS> -void checkReferenceDeleter(LHS& lhs, RHS& rhs) { - typedef typename LHS::deleter_type NewDel; - static_assert(std::is_reference<NewDel>::value, ""); - rhs.get_deleter().set_state(42); - assert(rhs.get_deleter().state() == 42); - assert(lhs.get_deleter().state() == 42); - lhs.get_deleter().set_state(99); - assert(lhs.get_deleter().state() == 99); - assert(rhs.get_deleter().state() == 99); -} - -template <class LHS, class RHS> -void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { - assert(lhs.get_deleter().state() == LHSVal); - assert(rhs.get_deleter().state() == RHSVal); -} - -template <class LHS, class RHS> -void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { - assert(lhs.get() == RHSVal); - assert(rhs.get() == nullptr); - assert(A::count == 1); - assert(B::count == 1); -} - -void checkNoneAlive() { - assert(A::count == 0); - assert(B::count == 0); -} - -int main() -{ - { - typedef std::unique_ptr<A> APtr; - typedef std::unique_ptr<B> BPtr; - { // explicit - BPtr b(new B); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - } - checkNoneAlive(); - { // implicit - BPtr b(new B); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - } - checkNoneAlive(); - } - { // test with moveable deleters - typedef std::unique_ptr<A, Deleter<A> > APtr; - typedef std::unique_ptr<B, Deleter<B> > BPtr; - { - Deleter<B> del(5); - BPtr b(new B, std::move(del)); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 0); - } - checkNoneAlive(); - { - Deleter<B> del(5); - BPtr b(new B, std::move(del)); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 0); - } - checkNoneAlive(); - - } - { // test with reference deleters - typedef std::unique_ptr<A, NCDeleter<A>& > APtr; - typedef std::unique_ptr<B, NCDeleter<A>& > BPtr; - NCDeleter<A> del(5); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkReferenceDeleter(a, b); - } - checkNoneAlive(); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkReferenceDeleter(a, b); - } - checkNoneAlive(); - } - { - typedef std::unique_ptr<A, CDeleter<A> > APtr; - typedef std::unique_ptr<B, CDeleter<B>& > BPtr; - CDeleter<B> del(5); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 5); - } - checkNoneAlive(); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 5); - } - checkNoneAlive(); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp deleted file mode 100644 index ed1fe8c2bdd4..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// Can't construct from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp deleted file mode 100644 index a1bf634b9995..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B, Deleter<B> > s(new B); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp deleted file mode 100644 index 7409199791b5..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp deleted file mode 100644 index 981ea706eb29..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp deleted file mode 100644 index d055b80627f9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - std::unique_ptr<B, Deleter<B> > s(new B); - std::unique_ptr<A, Deleter<A> > s2 = s; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp deleted file mode 100644 index 5b9b12e0d60b..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp deleted file mode 100644 index bef022cfc143..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp deleted file mode 100644 index 016eadcb2460..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class Deleter -{ - int state_; - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); - -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(5) {} - - template <class U> - Deleter(Deleter<U>&& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template <class U> - Deleter(const Deleter<U>& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - const std::unique_ptr<B, Deleter<B> > s; - std::unique_ptr<A, Deleter<A> > s2(s); // expected-error {{no matching constructor}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp deleted file mode 100644 index a475c17547c9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp deleted file mode 100644 index f0da5efb6917..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp deleted file mode 100644 index 1b8bb736df20..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(5) {} - - template <class U> - Deleter(Deleter<U>&& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template <class U> - Deleter(const Deleter<U>& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - const std::unique_ptr<B, Deleter<B> > s; - std::unique_ptr<A, Deleter<A> > s2 = s; // expected-error {{no viable conversion}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp deleted file mode 100644 index 095bec65669b..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp deleted file mode 100644 index 67a48a3e7a12..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int> p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr<int, Deleter> p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp deleted file mode 100644 index faa554d8b320..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -//============================================================================= -// TESTING std::unique_ptr::unique_ptr() -// -// Concerns: -// 1 The pointer constructor works for any default constructible deleter types. -// 2 The pointer constructor accepts pointers to derived types. -// 2 The stored type 'T' is allowed to be incomplete. -// -// Plan -// 1 Construct unique_ptr<T, D>'s with a pointer to 'T' and various deleter -// types (C-1) -// 2 Construct unique_ptr<T, D>'s with a pointer to 'D' and various deleter -// types where 'D' is derived from 'T'. (C-1,2) -// 3 Construct a unique_ptr<T, D> with a pointer to 'T' and various deleter -// types where 'T' is an incomplete type (C-1,3) - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// unique_ptr(pointer) ctor should only require default Deleter ctor - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - - -struct IncompleteT; - -IncompleteT* getIncomplete(); -void checkNumIncompleteTypeAlive(int i); - -template <class Del = std::default_delete<IncompleteT> > -struct StoresIncomplete { - std::unique_ptr<IncompleteT, Del> m_ptr; - StoresIncomplete() {} - explicit StoresIncomplete(IncompleteT* ptr) : m_ptr(ptr) {} - ~StoresIncomplete(); - - IncompleteT* get() const { return m_ptr.get(); } - Del& get_deleter() { return m_ptr.get_deleter(); } -}; - -void test_pointer() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, NCDeleter<A> > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); -} - -void test_derived() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A, NCDeleter<A> > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} - -void test_incomplete() -{ - { - IncompleteT* p = getIncomplete(); - checkNumIncompleteTypeAlive(1); - StoresIncomplete<> s(p); - assert(s.get() == p); - } - checkNumIncompleteTypeAlive(0); - { - IncompleteT* p = getIncomplete(); - checkNumIncompleteTypeAlive(1); - StoresIncomplete< NCDeleter<IncompleteT> > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - checkNumIncompleteTypeAlive(0); -} - -struct IncompleteT { - static int count; - IncompleteT() { ++count; } - ~IncompleteT() {--count; } -}; - -int IncompleteT::count = 0; - -IncompleteT* getIncomplete() { - return new IncompleteT; -} - -void checkNumIncompleteTypeAlive(int i) { - assert(IncompleteT::count == i); -} - -template <class Del> -StoresIncomplete<Del>::~StoresIncomplete() { } - -int main() -{ - test_pointer(); - test_derived(); - test_incomplete(); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp deleted file mode 100644 index 1af04b2c0033..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int, Deleter> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp deleted file mode 100644 index 9b7dd8c70f28..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int, Deleter&> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp deleted file mode 100644 index a917d87eeede..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr<int, void (*)(void*)> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp deleted file mode 100644 index 7ddd16265107..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -//============================================================================= -// TESTING unique_ptr(pointer, deleter) -// -// Concerns: -// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. -// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. -// 3 unique_ptr<T, D&>(pointer, deleter) does not require a CopyConstructible deleter. -// 4 unique_ptr<T, D const&>(pointer, deleter) does not require a CopyConstructible deleter. -// 5 unique_ptr(pointer, deleter) should work for derived pointers. -// 6 unique_ptr(pointer, deleter) should work with function pointers. -// 7 unique_ptr<void> should work. - - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -bool my_free_called = false; - -void my_free(void*) { - my_free_called = true; -} - -int main() -{ - { // MoveConstructible deleter (C-1) - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5)); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { // CopyConstructible deleter (C-2) - A* p = new A; - assert(A::count == 1); - CopyDeleter<A> d(5); - std::unique_ptr<A, CopyDeleter<A> > s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { // Reference deleter (C-3) - A* p = new A; - assert(A::count == 1); - NCDeleter<A> d(5); - std::unique_ptr<A, NCDeleter<A>&> s(p, d); - assert(s.get() == p); - assert(&s.get_deleter() == &d); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); - { // Const Reference deleter (C-4) - A* p = new A; - assert(A::count == 1); - NCConstDeleter<A> d(5); - std::unique_ptr<A, NCConstDeleter<A> const&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - assert(&s.get_deleter() == &d); - } - assert(A::count == 0); - { // Derived pointers (C-5) - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5)); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); - { // Void and function pointers (C-6,7) - { - int i = 0; - std::unique_ptr<void, void(*)(void*)> s(&i, my_free); - assert(s.get() == &i); - assert(s.get_deleter() == my_free); - assert(!my_free_called); - } - assert(my_free_called); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp deleted file mode 100644 index dadd4ecbe590..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test release - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int> p(new int(3)); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete j; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp deleted file mode 100644 index 2cf7f8b77568..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(new A); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp deleted file mode 100644 index d0a03be80326..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test swap - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - int state_; - static int count; - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A(1); - std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1)); - A* p2 = new A(2); - std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2)); - assert(s1.get() == p1); - assert(*s1 == A(1)); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(*s2 == A(2)); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(*s1 == A(2)); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(*s2 == A(1)); - assert(s2.get_deleter().state() == 1); - assert(A::count == 2); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp deleted file mode 100644 index 24fa6beb4273..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get - -#include <memory> -#include <cassert> - -int main() -{ - int* p = new int; - std::unique_ptr<int> s(p); - assert(s.get() == p); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp deleted file mode 100644 index 5ed8a22b14c4..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get_deleter() - -#include <memory> -#include <cassert> - -struct Deleter -{ - void operator()(void*) {} - - int test() {return 5;} - int test() const {return 6;} -}; - -int main() -{ - { - std::unique_ptr<int, Deleter> p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr<int, Deleter> p; - assert(p.get_deleter().test() == 6); - } -} diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp index b9f8ee0746c3..5a0d9259c11d 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp @@ -51,11 +51,11 @@ struct Bar : public Foo { int main() { - { // https://llvm.org/bugs/show_bug.cgi?id=18843 + { // https://bugs.llvm.org/show_bug.cgi?id=18843 std::shared_ptr<T const> t1(new T); std::shared_ptr<T const> t2(std::make_shared<T>()); } - { // https://llvm.org/bugs/show_bug.cgi?id=27115 + { // https://bugs.llvm.org/show_bug.cgi?id=27115 int x = 42; std::shared_ptr<Bar> t1(new Bar(42)); assert(t1->shared_from_this() == t1); @@ -84,12 +84,12 @@ int main() T* ptr = new T; std::shared_ptr<T> s(ptr); { - // Don't re-initialize the "enabled_shared_from_this" base + // Don't re-initialize the "enable_shared_from_this" base // because it already references a non-expired shared_ptr. std::shared_ptr<T> s2(ptr, &nullDeleter); } #if TEST_STD_VER > 14 - // The enabled_shared_from_this base should still be referencing + // The enable_shared_from_this base should still be referencing // the original shared_ptr. assert(!ptr->weak_from_this().expired()); #endif diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/enabled_hash.pass.cpp index 31f7ce367e3d..e9237c534fba 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/enabled_hash.pass.cpp @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// -// <memory> - -// unique_ptr +// UNSUPPORTED: c++98, c++03 -// Test unique_ptr<T[]>(pointer) ctor +// <memory> -// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter +// Test that <memory> provides all of the arithmetic, enum, and pointer +// hash specializations. #include <memory> -int main() -{ - std::unique_ptr<int[], void (*)(void*)> p(new int); +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp index 990cb58722b1..5fba1fc0460b 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp @@ -20,11 +20,25 @@ #include <memory> #include <cassert> +#if TEST_STD_VER >= 11 +#include "poisoned_hash_helper.hpp" + +struct A {}; +#endif + int main() { + { int* ptr = new int; std::shared_ptr<int> p(ptr); std::hash<std::shared_ptr<int> > f; std::size_t h = f(p); assert(h == std::hash<int*>()(ptr)); + } +#if TEST_STD_VER >= 11 + { + test_hash_enabled_for_type<std::shared_ptr<int>>(); + test_hash_enabled_for_type<std::shared_ptr<A>>(); + } +#endif } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp index 5cd4ab1f83d0..fc346d4dce7d 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp @@ -20,11 +20,80 @@ #include <memory> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +#include "poisoned_hash_helper.hpp" +#include "deleter_types.h" +#include "min_allocator.h" + +template <class ValueT, class Del> +void test_enabled_with_deleter() { + using UPtr = std::unique_ptr<ValueT, Del>; + using pointer = typename UPtr::pointer; + using RawDel = typename std::decay<Del>::type; + RawDel d(1); + UPtr p(nullptr, std::forward<Del>(d)); + test_hash_enabled_for_type<UPtr>(p); + test_hash_enabled_for_type<pointer>(); +} + +template <class ValueT, class Del> +void test_disabled_with_deleter() { + using UPtr = std::unique_ptr<ValueT, Del>; + using pointer = typename UPtr::pointer; + test_hash_disabled_for_type<UPtr>(); + test_hash_disabled_for_type<pointer>(); +} + +namespace std { + +template <class T> +struct hash<::min_pointer<T, std::integral_constant<size_t, 1>>> { + size_t operator()(::min_pointer<T, std::integral_constant<size_t, 1>> p) const noexcept(false) { + if (!p) return 0; + return std::hash<T*>{}(std::addressof(*p)); + } +}; +} + +struct A {}; + +#endif // TEST_STD_VER >= 11 + int main() { + { int* ptr = new int; std::unique_ptr<int> p(ptr); std::hash<std::unique_ptr<int> > f; + ASSERT_NOT_NOEXCEPT(f(p)); std::size_t h = f(p); assert(h == std::hash<int*>()(ptr)); + } +#if TEST_STD_VER >= 11 + { + test_enabled_with_deleter<int, Deleter<int>>(); + test_enabled_with_deleter<int[], Deleter<int[]>>(); + test_enabled_with_deleter<int, CopyDeleter<int>>(); + test_enabled_with_deleter<int, CopyDeleter<int[]>>(); + test_enabled_with_deleter<int, NCDeleter<int>&>(); + test_enabled_with_deleter<int[], NCDeleter<int[]>&>(); + test_enabled_with_deleter<int, NCConstDeleter<int> const&>(); + test_enabled_with_deleter<int[], NCConstDeleter<int[]> const&>(); + } + { + test_enabled_with_deleter<int, PointerDeleter<int, 1>>(); + test_enabled_with_deleter<int[], PointerDeleter<int[], 1>>(); + test_enabled_with_deleter<A, PointerDeleter<A, 1>>(); + test_enabled_with_deleter<A[], PointerDeleter<A[], 1>>(); + +#if TEST_STD_VER > 14 + test_disabled_with_deleter<int, PointerDeleter<int, 0>>(); + test_disabled_with_deleter<int[], PointerDeleter<int[], 0>>(); + test_disabled_with_deleter<A, PointerDeleter<A, 0>>(); + test_disabled_with_deleter<A[], PointerDeleter<A[], 0>>(); +#endif + } +#endif } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp index 3bad537e3431..d1e13139bce3 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp index 5cc1234ad34e..08e31e8d7d70 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp index a89c0dbd2207..f8f550deb051 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp index 821cea6868e4..1ea11ceed43d 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp index 66be756d54fd..9a5792f519d5 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp index 493ba7fcc94d..aac9af082d74 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp index 4820d05420a2..fa79e7cdd9ad 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp index ef8dc822102f..c650899f764a 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp index a13a7d57ab96..cbcc4ddbbc2c 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp index 6dfe3166c8c5..eb5e246833c2 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h deleted file mode 100644 index 6b3f1e2ab0de..000000000000 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// Example move-only deleter - -#ifndef DELETER_H -#define DELETER_H - -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -#if TEST_STD_VER >= 11 -#define DELETE_FUNCTION = delete -#else -#define DELETE_FUNCTION { assert(false); } -#endif - -struct test_deleter_base -{ - static int count; - static int dealloc_count; -}; - -int test_deleter_base::count = 0; -int test_deleter_base::dealloc_count = 0; - -template <class T> -class test_deleter - : public test_deleter_base -{ - int state_; - -public: - - test_deleter() : state_(0) {++count;} - explicit test_deleter(int s) : state_(s) {++count;} - test_deleter(const test_deleter& d) - : state_(d.state_) {++count;} - ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;} - - test_deleter* operator&() const DELETE_FUNCTION; -}; - -template <class T> -void -swap(test_deleter<T>& x, test_deleter<T>& y) -{ - test_deleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - -#endif // DELETER_H diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp index a6c62496fd62..05a199cced63 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp index 21cdf4a13e47..10d53c1268aa 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp @@ -10,6 +10,7 @@ // <memory> // shared_ptr +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp index f8fdb7a09478..3ad3232a90b4 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp @@ -10,6 +10,7 @@ // <memory> // template<class Y> explicit shared_ptr(auto_ptr<Y>&& r); +// REQUIRES: c++98 || c++03 || c++11 || c++14 #include <memory> @@ -85,6 +86,7 @@ int main() // Without rvalue references, ptr got copied into // the shared_ptr destructor and the copy was // destroyed during unwinding. + (void) raw_ptr; // silence 'unused variable' warning assert(A::count == 0); assert(B::count == 0); #endif diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp index 7d4dc38d4b9a..bf2a304011c8 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp index 8a6cd0f352ff..aabc66a03c40 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp @@ -13,7 +13,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" #include "min_allocator.h" diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp index 2e6441d66316..55e52f49c752 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp @@ -14,7 +14,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" struct A diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp index 009b4cfc00f9..e82f0fdcc9ed 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp @@ -24,7 +24,7 @@ #include "test_macros.h" #include "count_new.hpp" -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp index 43eedee176c2..c813f6f6f9c5 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp index b0facfc1a6eb..96a1779fe870 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp @@ -13,7 +13,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" #include "min_allocator.h" diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp index 388599bd7015..47d24c349871 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp @@ -14,7 +14,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" struct A diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp index 7b40d6df2164..13c2d435b93a 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp @@ -22,7 +22,7 @@ #include <cstdlib> #include "count_new.hpp" -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp index 877577c9ce58..17289197d35e 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp @@ -80,6 +80,7 @@ int main() assert(B::count == 1); assert(ptr.get() == raw_ptr); #else + (void) raw_ptr; // silence 'unused variable' warning assert(A::count == 0); assert(B::count == 0); assert(ptr.get() == 0); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp index 8d782716b94f..2a7ac9979d02 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -59,7 +59,7 @@ int main() assert(p->get_char() == 'e'); } - { // https://llvm.org/bugs/show_bug.cgi?id=24137 + { // https://bugs.llvm.org/show_bug.cgi?id=24137 std::shared_ptr<Foo> p1 = std::make_shared<Foo>(); assert(p1.get()); std::shared_ptr<const Foo> p2 = std::make_shared<const Foo>(); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp index 33965dfeb33c..c33133d79fdc 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct B { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp index 09070e2c059b..58262eb4334e 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" struct B diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp index 3acd2f8c6f2d..9f6f1bc75c71 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp @@ -11,10 +11,11 @@ // shared_ptr -// template <class U> bool owner_before(shared_ptr<U> const& b) const; +// template <class U> bool owner_before(shared_ptr<U> const& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -25,4 +26,5 @@ int main() assert(!p2.owner_before(p1)); assert(p1.owner_before(p3) || p3.owner_before(p1)); assert(p3.owner_before(p1) == p3.owner_before(p2)); + ASSERT_NOEXCEPT(p1.owner_before(p2)); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp index 33447ba7da00..560293bbedb7 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp @@ -11,10 +11,11 @@ // shared_ptr -// template <class U> bool owner_before(weak_ptr<U> const& b) const; +// template <class U> bool owner_before(weak_ptr<U> const& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -28,4 +29,5 @@ int main() assert(!p2.owner_before(w1)); assert(p1.owner_before(w3) || p3.owner_before(w1)); assert(p3.owner_before(w1) == p3.owner_before(w2)); + ASSERT_NOEXCEPT(p1.owner_before(w2)); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp index 142eba2d9647..7ab60da77c7d 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp @@ -16,9 +16,9 @@ // : binary_function<shared_ptr<T>, shared_ptr<T>, bool> // { // typedef bool result_type; -// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; -// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; +// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const noexcept; +// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept; +// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept; // }; // // template <class T> @@ -26,22 +26,22 @@ // : binary_function<weak_ptr<T>, weak_ptr<T>, bool> // { // typedef bool result_type; -// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; +// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const noexcept; +// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept; +// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept; // }; // // Added in C++17 // template<> struct owner_less<void> // { // template<class T, class U> -// bool operator()(shared_ptr<T> const&, shared_ptr<U> const&) const; +// bool operator()(shared_ptr<T> const&, shared_ptr<U> const&) const noexcept; // template<class T, class U> -// bool operator()(shared_ptr<T> const&, weak_ptr<U> const&) const; +// bool operator()(shared_ptr<T> const&, weak_ptr<U> const&) const noexcept; // template<class T, class U> -// bool operator()(weak_ptr<T> const&, shared_ptr<U> const&) const; +// bool operator()(weak_ptr<T> const&, shared_ptr<U> const&) const noexcept; // template<class T, class U> -// bool operator()(weak_ptr<T> const&, weak_ptr<U> const&) const; +// bool operator()(weak_ptr<T> const&, weak_ptr<U> const&) const noexcept; // // typedef unspecified is_transparent; // }; @@ -69,16 +69,19 @@ int main() static_assert((std::is_same<std::shared_ptr<int>, CS::first_argument_type>::value), "" ); static_assert((std::is_same<std::shared_ptr<int>, CS::second_argument_type>::value), "" ); static_assert((std::is_same<bool, CS::result_type>::value), "" ); - + assert(!cs(p1, p2)); assert(!cs(p2, p1)); assert(cs(p1 ,p3) || cs(p3, p1)); assert(cs(p3, p1) == cs(p3, p2)); + ASSERT_NOEXCEPT(cs(p1, p1)); assert(!cs(p1, w2)); assert(!cs(p2, w1)); assert(cs(p1, w3) || cs(p3, w1)); assert(cs(p3, w1) == cs(p3, w2)); + ASSERT_NOEXCEPT(cs(p1, w1)); + ASSERT_NOEXCEPT(cs(w1, p1)); } { typedef std::owner_less<std::weak_ptr<int> > CS; @@ -92,11 +95,14 @@ int main() assert(!cs(w2, w1)); assert(cs(w1, w3) || cs(w3, w1)); assert(cs(w3, w1) == cs(w3, w2)); + ASSERT_NOEXCEPT(cs(w1, w1)); assert(!cs(w1, p2)); assert(!cs(w2, p1)); assert(cs(w1, p3) || cs(w3, p1)); assert(cs(w3, p1) == cs(w3, p2)); + ASSERT_NOEXCEPT(cs(w1, p1)); + ASSERT_NOEXCEPT(cs(p1, w1)); } #if TEST_STD_VER > 14 { @@ -111,6 +117,10 @@ int main() cmp(sp1, sp3); cmp(wp1, sp1); cmp(wp1, wp1); + ASSERT_NOEXCEPT(cmp(sp1, sp1)); + ASSERT_NOEXCEPT(cmp(sp1, wp1)); + ASSERT_NOEXCEPT(cmp(wp1, sp1)); + ASSERT_NOEXCEPT(cmp(wp1, wp1)); } { // test heterogeneous lookups diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp index 4aa49cfe8a24..458f8a11ed12 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp @@ -11,10 +11,11 @@ // weak_ptr -// template<class U> bool owner_before(const shared_ptr<U>& b); +// template<class U> bool owner_before(const shared_ptr<U>& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -28,4 +29,6 @@ int main() assert(!w2.owner_before(p1)); assert(w1.owner_before(p3) || w3.owner_before(p1)); assert(w3.owner_before(p1) == w3.owner_before(p2)); +// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted + LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(p2)); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp index 9fe2b6e39035..5cd171a53021 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp @@ -11,10 +11,11 @@ // weak_ptr -// template<class U> bool owner_before(const weak_ptr<U>& b); +// template<class U> bool owner_before(const weak_ptr<U>& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -28,4 +29,6 @@ int main() assert(!w2.owner_before(w1)); assert(w1.owner_before(w3) || w3.owner_before(w1)); assert(w3.owner_before(w1) == w3.owner_before(w2)); +// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted + LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(w2)); } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp index 61523e4872d4..85b14726617f 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -37,8 +37,16 @@ namespace std typedef S<T> type; }; +// P0548 + template <class T> + struct common_type< ::S<T>, ::S<T> > { + typedef S<T> type; + }; + template <> struct common_type< ::S<long>, long> {}; template <> struct common_type<long, ::S<long> > {}; + template <> struct common_type< ::X<float> > {}; + template <> struct common_type< ::X<double>, ::X<double> > {}; } #if TEST_STD_VER >= 11 @@ -88,6 +96,9 @@ void test_bullet_two() { static_assert(std::is_same<CommonType<int const>, int>::value, ""); static_assert(std::is_same<CommonType<int volatile[]>, int volatile*>::value, ""); static_assert(std::is_same<CommonType<void(&)()>, void(*)()>::value, ""); + + static_assert(no_common_type<X<float> >::value, ""); + static_assert(no_common_type<X<double> >::value, ""); } template <class T, class U, class Expect> @@ -284,4 +295,18 @@ int main() test_bullet_three_two(); test_bullet_four(); #endif + +// P0548 + static_assert((std::is_same<std::common_type<S<int> >::type, S<int> >::value), ""); + static_assert((std::is_same<std::common_type<S<int>, S<int> >::type, S<int> >::value), ""); + + static_assert((std::is_same<std::common_type<int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<volatile int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), ""); + + static_assert((std::is_same<std::common_type<int, int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int, int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int, const int>::type, int>::value), ""); } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp index bcd839849453..4f45a0340a91 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp @@ -33,4 +33,10 @@ int main() test_decay<int[3], int*>(); test_decay<const int[3], const int*>(); test_decay<void(), void (*)()>(); +#if TEST_STD_VER > 11 + test_decay<int(int) const, int(int) const>(); + test_decay<int(int) volatile, int(int) volatile>(); + test_decay<int(int) &, int(int) &>(); + test_decay<int(int) &&, int(int) &&>(); +#endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp index 8cb5853bbc6d..eac4e4a089fe 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp @@ -26,7 +26,6 @@ struct wat struct F {}; struct FD : public F {}; -struct NotDerived {}; template <class T, class U> void test_result_of_imp() @@ -43,7 +42,6 @@ void test_result_of_imp() int main() { - typedef NotDerived ND; { typedef char F::*PMD; test_result_of_imp<PMD(F &), char &>(); diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp index 410e47e03bcc..b00798b72240 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -17,24 +17,32 @@ #include "test_macros.h" enum E { V = INT_MIN }; -enum F { W = UINT_MAX }; -int main() -{ #if !defined(_WIN32) || defined(__MINGW32__) - typedef unsigned ExpectUnsigned; + #define TEST_UNSIGNED_UNDERLYING_TYPE 1 #else - typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard + #define TEST_UNSIGNED_UNDERLYING_TYPE 0 // MSVC's ABI doesn't follow the Standard #endif + +#if TEST_UNSIGNED_UNDERLYING_TYPE +enum F { W = UINT_MAX }; +#endif // TEST_UNSIGNED_UNDERLYING_TYPE + +int main() +{ static_assert((std::is_same<std::underlying_type<E>::type, int>::value), "E has the wrong underlying type"); - static_assert((std::is_same<std::underlying_type<F>::type, ExpectUnsigned>::value), +#if TEST_UNSIGNED_UNDERLYING_TYPE + static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value), "F has the wrong underlying type"); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE #if TEST_STD_VER > 11 static_assert((std::is_same<std::underlying_type_t<E>, int>::value), ""); - static_assert((std::is_same<std::underlying_type_t<F>, ExpectUnsigned>::value), ""); -#endif +#if TEST_UNSIGNED_UNDERLYING_TYPE + static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), ""); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE +#endif // TEST_STD_VER > 11 #if TEST_STD_VER >= 11 enum G : char { }; @@ -43,6 +51,6 @@ int main() "G has the wrong underlying type"); #if TEST_STD_VER > 11 static_assert((std::is_same<std::underlying_type_t<G>, char>::value), ""); -#endif +#endif // TEST_STD_VER > 11 #endif // TEST_STD_VER >= 11 } diff --git a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp index 05ef99d0ebf4..2d10fb0040a7 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp @@ -13,7 +13,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 -// XFAIL: gcc-5.1 gcc-5.2 +// XFAIL: gcc-5.1, gcc-5.2 #include <type_traits> diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp index 32e4f06beb04..c340ba69cda3 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp @@ -13,6 +13,7 @@ #include <type_traits> #include <cstddef> // for std::nullptr_t + #include "test_macros.h" template <class T> @@ -79,22 +80,27 @@ int main() test_is_function<int(Abstract *)>(); test_is_function<void(...)>(); - test_is_not_function<std::nullptr_t>(); - test_is_not_function<void>(); - test_is_not_function<int>(); - test_is_not_function<int&>(); - test_is_not_function<int&&>(); - test_is_not_function<int*>(); - test_is_not_function<double>(); - test_is_not_function<char[3]>(); - test_is_not_function<char[]>(); - test_is_not_function<Union>(); - test_is_not_function<Enum>(); - test_is_not_function<FunctionPtr>(); // function pointer is not a function - test_is_not_function<Empty>(); - test_is_not_function<bit_zero>(); - test_is_not_function<NotEmpty>(); - test_is_not_function<Abstract>(); - test_is_not_function<Abstract*>(); - test_is_not_function<incomplete_type>(); + test_is_not_function<std::nullptr_t>(); + test_is_not_function<void>(); + test_is_not_function<int>(); + test_is_not_function<int&>(); + test_is_not_function<int&&>(); + test_is_not_function<int*>(); + test_is_not_function<double>(); + test_is_not_function<char[3]>(); + test_is_not_function<char[]>(); + test_is_not_function<Union>(); + test_is_not_function<Enum>(); + test_is_not_function<FunctionPtr>(); // function pointer is not a function + test_is_not_function<Empty>(); + test_is_not_function<bit_zero>(); + test_is_not_function<NotEmpty>(); + test_is_not_function<Abstract>(); + test_is_not_function<Abstract*>(); + test_is_not_function<incomplete_type>(); + +#if TEST_STD_VER >= 11 + test_is_function<void() noexcept>(); + test_is_function<void() const && noexcept>(); +#endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp index d4043f48f98e..a63a88c4d18b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp @@ -97,4 +97,10 @@ int main() test_is_not_member_pointer<NotEmpty>(); test_is_not_member_pointer<Abstract>(); test_is_not_member_pointer<incomplete_type>(); + +#if TEST_STD_VER >= 11 + test_is_member_pointer<int (Empty::*)(int, ...) const>(); + test_is_member_pointer<int (Empty::*)(int, long, long) const noexcept>(); + test_is_member_pointer<int (Empty::*)() & noexcept>(); +#endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp index a895a8d447b6..691c549b5e78 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp @@ -52,90 +52,175 @@ struct incomplete_type; int main() { - test_member_function_pointer<void (Class::*)()>(); - test_member_function_pointer<void (Class::*)(int)>(); - test_member_function_pointer<void (Class::*)(int, char)>(); + test_member_function_pointer<void (Class::*)()>(); + test_member_function_pointer<void (Class::*)(int)>(); + test_member_function_pointer<void (Class::*)(int, char)>(); - test_member_function_pointer<void (Class::*)() const>(); - test_member_function_pointer<void (Class::*)(int) const>(); - test_member_function_pointer<void (Class::*)(int, char) const>(); + test_member_function_pointer<void (Class::*)() const>(); + test_member_function_pointer<void (Class::*)(int) const>(); + test_member_function_pointer<void (Class::*)(int, char) const>(); - test_member_function_pointer<void (Class::*)() volatile>(); - test_member_function_pointer<void (Class::*)(int) volatile>(); - test_member_function_pointer<void (Class::*)(int, char) volatile>(); + test_member_function_pointer<void (Class::*)() volatile>(); + test_member_function_pointer<void (Class::*)(int) volatile>(); + test_member_function_pointer<void (Class::*)(int, char) volatile>(); - test_member_function_pointer<void (Class::*)(...)>(); - test_member_function_pointer<void (Class::*)(int, ...)>(); - test_member_function_pointer<void (Class::*)(int, char, ...)>(); + test_member_function_pointer<void (Class::*)(...)>(); + test_member_function_pointer<void (Class::*)(int, ...)>(); + test_member_function_pointer<void (Class::*)(int, char, ...)>(); - test_member_function_pointer<void (Class::*)(...) const>(); - test_member_function_pointer<void (Class::*)(int, ...) const>(); - test_member_function_pointer<void (Class::*)(int, char, ...) const>(); + test_member_function_pointer<void (Class::*)(...) const>(); + test_member_function_pointer<void (Class::*)(int, ...) const>(); + test_member_function_pointer<void (Class::*)(int, char, ...) const>(); + + test_member_function_pointer<void (Class::*)(...) volatile>(); + test_member_function_pointer<void (Class::*)(int, ...) volatile>(); + test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); - test_member_function_pointer<void (Class::*)(...) volatile>(); - test_member_function_pointer<void (Class::*)(int, ...) volatile>(); - test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); // reference qualifiers on functions are a C++11 extension #if TEST_STD_VER >= 11 - test_member_function_pointer<void (Class::*)() &>(); - test_member_function_pointer<void (Class::*)(int) &>(); - test_member_function_pointer<void (Class::*)(int, char) &>(); - test_member_function_pointer<void (Class::*)(...) &>(); - test_member_function_pointer<void (Class::*)(int,...) &>(); - test_member_function_pointer<void (Class::*)(int, char,...) &>(); - - test_member_function_pointer<void (Class::*)() const &>(); - test_member_function_pointer<void (Class::*)(int) const &>(); - test_member_function_pointer<void (Class::*)(int, char) const &>(); - test_member_function_pointer<void (Class::*)(...) const &>(); - test_member_function_pointer<void (Class::*)(int,...) const &>(); - test_member_function_pointer<void (Class::*)(int, char,...) const &>(); - - test_member_function_pointer<void (Class::*)() volatile &>(); - test_member_function_pointer<void (Class::*)(int) volatile &>(); - test_member_function_pointer<void (Class::*)(int, char) volatile &>(); - test_member_function_pointer<void (Class::*)(...) volatile &>(); - test_member_function_pointer<void (Class::*)(int,...) volatile &>(); - test_member_function_pointer<void (Class::*)(int, char,...) volatile &>(); - - test_member_function_pointer<void (Class::*)() const volatile &>(); - test_member_function_pointer<void (Class::*)(int) const volatile &>(); - test_member_function_pointer<void (Class::*)(int, char) const volatile &>(); - test_member_function_pointer<void (Class::*)(...) const volatile &>(); - test_member_function_pointer<void (Class::*)(int,...) const volatile &>(); - test_member_function_pointer<void (Class::*)(int, char,...) const volatile &>(); - - // RValue qualifiers - test_member_function_pointer<void (Class::*)() &&>(); - test_member_function_pointer<void (Class::*)(int) &&>(); - test_member_function_pointer<void (Class::*)(int, char) &&>(); - test_member_function_pointer<void (Class::*)(...) &&>(); - test_member_function_pointer<void (Class::*)(int,...) &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) &&>(); - - test_member_function_pointer<void (Class::*)() const &&>(); - test_member_function_pointer<void (Class::*)(int) const &&>(); - test_member_function_pointer<void (Class::*)(int, char) const &&>(); - test_member_function_pointer<void (Class::*)(...) const &&>(); - test_member_function_pointer<void (Class::*)(int,...) const &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) const &&>(); - - test_member_function_pointer<void (Class::*)() volatile &&>(); - test_member_function_pointer<void (Class::*)(int) volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char) volatile &&>(); - test_member_function_pointer<void (Class::*)(...) volatile &&>(); - test_member_function_pointer<void (Class::*)(int,...) volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>(); - - test_member_function_pointer<void (Class::*)() const volatile &&>(); - test_member_function_pointer<void (Class::*)(int) const volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char) const volatile &&>(); - test_member_function_pointer<void (Class::*)(...) const volatile &&>(); - test_member_function_pointer<void (Class::*)(int,...) const volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>(); + // Noexcept qualifiers + test_member_function_pointer<void (Class::*)() noexcept>(); + test_member_function_pointer<void (Class::*)(int) noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) noexcept>(); + + test_member_function_pointer<void (Class::*)() const noexcept>(); + test_member_function_pointer<void (Class::*)(int) const noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const noexcept>(); + + test_member_function_pointer<void (Class::*)() volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int) volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) volatile noexcept>(); + + test_member_function_pointer<void (Class::*)(...) noexcept>(); + test_member_function_pointer<void (Class::*)(int, ...) noexcept>(); + test_member_function_pointer<void (Class::*)(int, char, ...) noexcept>(); + + test_member_function_pointer<void (Class::*)(...) const noexcept>(); + test_member_function_pointer<void (Class::*)(int, ...) const noexcept>(); + test_member_function_pointer<void (Class::*)(int, char, ...) const noexcept>(); + + test_member_function_pointer<void (Class::*)(...) volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int, ...) volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int, char, ...) volatile noexcept>(); + + // lvalue qualifiers + test_member_function_pointer<void (Class::*)() &>(); + test_member_function_pointer<void (Class::*)(int) &>(); + test_member_function_pointer<void (Class::*)(int, char) &>(); + test_member_function_pointer<void (Class::*)(...) &>(); + test_member_function_pointer<void (Class::*)(int,...) &>(); + test_member_function_pointer<void (Class::*)(int, char,...) &>(); + + test_member_function_pointer<void (Class::*)() const &>(); + test_member_function_pointer<void (Class::*)(int) const &>(); + test_member_function_pointer<void (Class::*)(int, char) const &>(); + test_member_function_pointer<void (Class::*)(...) const &>(); + test_member_function_pointer<void (Class::*)(int,...) const &>(); + test_member_function_pointer<void (Class::*)(int, char,...) const &>(); + + test_member_function_pointer<void (Class::*)() volatile &>(); + test_member_function_pointer<void (Class::*)(int) volatile &>(); + test_member_function_pointer<void (Class::*)(int, char) volatile &>(); + test_member_function_pointer<void (Class::*)(...) volatile &>(); + test_member_function_pointer<void (Class::*)(int,...) volatile &>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile &>(); + + test_member_function_pointer<void (Class::*)() const volatile &>(); + test_member_function_pointer<void (Class::*)(int) const volatile &>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile &>(); + test_member_function_pointer<void (Class::*)(...) const volatile &>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile &>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile &>(); + + // Lvalue qualifiers with noexcept + test_member_function_pointer<void (Class::*)() & noexcept>(); + test_member_function_pointer<void (Class::*)(int) & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) & noexcept>(); + test_member_function_pointer<void (Class::*)(...) & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) & noexcept>(); + + test_member_function_pointer<void (Class::*)() const & noexcept>(); + test_member_function_pointer<void (Class::*)(int) const & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const & noexcept>(); + test_member_function_pointer<void (Class::*)(...) const & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const & noexcept>(); + + test_member_function_pointer<void (Class::*)() volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(...) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile & noexcept>(); + + test_member_function_pointer<void (Class::*)() const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(...) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile & noexcept>(); + + // RValue qualifiers + test_member_function_pointer<void (Class::*)() &&>(); + test_member_function_pointer<void (Class::*)(int) &&>(); + test_member_function_pointer<void (Class::*)(int, char) &&>(); + test_member_function_pointer<void (Class::*)(...) &&>(); + test_member_function_pointer<void (Class::*)(int,...) &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) &&>(); + + test_member_function_pointer<void (Class::*)() const &&>(); + test_member_function_pointer<void (Class::*)(int) const &&>(); + test_member_function_pointer<void (Class::*)(int, char) const &&>(); + test_member_function_pointer<void (Class::*)(...) const &&>(); + test_member_function_pointer<void (Class::*)(int,...) const &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) const &&>(); + + test_member_function_pointer<void (Class::*)() volatile &&>(); + test_member_function_pointer<void (Class::*)(int) volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char) volatile &&>(); + test_member_function_pointer<void (Class::*)(...) volatile &&>(); + test_member_function_pointer<void (Class::*)(int,...) volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>(); + + test_member_function_pointer<void (Class::*)() const volatile &&>(); + test_member_function_pointer<void (Class::*)(int) const volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile &&>(); + test_member_function_pointer<void (Class::*)(...) const volatile &&>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>(); + + // RValue qualifiers with noexcept + test_member_function_pointer<void (Class::*)() && noexcept>(); + test_member_function_pointer<void (Class::*)(int) && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) && noexcept>(); + test_member_function_pointer<void (Class::*)(...) && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) && noexcept>(); + + test_member_function_pointer<void (Class::*)() const && noexcept>(); + test_member_function_pointer<void (Class::*)(int) const && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const && noexcept>(); + test_member_function_pointer<void (Class::*)(...) const && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const && noexcept>(); + + test_member_function_pointer<void (Class::*)() volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(...) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile && noexcept>(); + + test_member_function_pointer<void (Class::*)() const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(...) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile && noexcept>(); #endif // LWG#2582 - static_assert(!std::is_member_function_pointer<incomplete_type>::value, ""); + static_assert(!std::is_member_function_pointer<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp index a54adf10258f..99ca74cc2fa9 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp @@ -65,6 +65,14 @@ class Abstract virtual ~Abstract() = 0; }; +template <class> +struct AbstractTemplate { + virtual void test() = 0; +}; + +template <> +struct AbstractTemplate<double> {}; + int main() { test_is_not_abstract<void>(); @@ -81,4 +89,6 @@ int main() test_is_not_abstract<NotEmpty>(); test_is_abstract<Abstract>(); + test_is_abstract<AbstractTemplate<int> >(); + test_is_not_abstract<AbstractTemplate<double> >(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp new file mode 100644 index 000000000000..9c72d4d44ce5 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <type_traits> + +// template <class T> struct is_aggregate; +// template <class T> constexpr bool is_aggregate_v = is_aggregate<T>::value; + +#include <type_traits> +#include "test_macros.h" + +template <class T> +void test_true() +{ +#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + static_assert( std::is_aggregate<T>::value, ""); + static_assert( std::is_aggregate<const T>::value, ""); + static_assert( std::is_aggregate<volatile T>::value, ""); + static_assert( std::is_aggregate<const volatile T>::value, ""); + static_assert( std::is_aggregate_v<T>, ""); + static_assert( std::is_aggregate_v<const T>, ""); + static_assert( std::is_aggregate_v<volatile T>, ""); + static_assert( std::is_aggregate_v<const volatile T>, ""); +#endif +} + +template <class T> +void test_false() +{ +#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + static_assert(!std::is_aggregate<T>::value, ""); + static_assert(!std::is_aggregate<const T>::value, ""); + static_assert(!std::is_aggregate<volatile T>::value, ""); + static_assert(!std::is_aggregate<const volatile T>::value, ""); + static_assert(!std::is_aggregate_v<T>, ""); + static_assert(!std::is_aggregate_v<const T>, ""); + static_assert(!std::is_aggregate_v<volatile T>, ""); + static_assert(!std::is_aggregate_v<const volatile T>, ""); +#endif +} + +struct Aggregate {}; +struct HasCons { HasCons(int); }; +struct HasPriv { + void PreventUnusedPrivateMemberWarning(); +private: + int x; +}; +struct Union { int x; void* y; }; + + +int main () +{ + { + test_false<void>(); + test_false<int>(); + test_false<void*>(); + test_false<void()>(); + test_false<void() const>(); + test_false<void(Aggregate::*)(int) const>(); + test_false<Aggregate&>(); + test_false<HasCons>(); + test_false<HasPriv>(); + } + { + test_true<Aggregate>(); + test_true<Aggregate[]>(); + test_true<Aggregate[42][101]>(); + test_true<Union>(); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp index f4736e713422..3955d4bc3306 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp @@ -82,5 +82,4 @@ int main() // pointer to incomplete template type test_is_assignable<X<D>*&, X<D>*> (); - test_is_not_assignable<Incomplete&, Incomplete const&>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp index f6ae401533a9..9d2ec5edea58 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp @@ -251,6 +251,7 @@ int main() LIBCPP_STATIC_ASSERT( clang_disallows_valid_static_cast_bug != std::__libcpp_is_constructible<int&&, ExplicitTo<int&&>>::value, ""); + ((void)clang_disallows_valid_static_cast_bug); // Prevent unused warning #else static_assert(clang_disallows_valid_static_cast_bug == false, ""); LIBCPP_STATIC_ASSERT(std::__libcpp_is_constructible<int&&, ExplicitTo<int&&>>::value, ""); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp index 59aa5e26a292..7ead5f5d5df9 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp @@ -77,7 +77,7 @@ int main() #endif // Before C++14, void was not a literal type -// In C++14, cv-void is is a literal type +// In C++14, cv-void is a literal type #if TEST_STD_VER < 14 test_is_not_literal_type<void>(); #else diff --git a/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp index b54a08f5575b..29fb7a8431f1 100644 --- a/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp @@ -17,37 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator == ( const X &lhs, const X &rhs ) - { return lhs.i_ == rhs.i_ ; } +constexpr bool operator==(const X& lhs, const X& rhs) { + return lhs.i_ == rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( !(o1 == T(1)), "" ); - static_assert ( (o2 == T(1)), "" ); - static_assert ( !(o3 == T(1)), "" ); - static_assert ( (o3 == T(2)), "" ); - static_assert ( (o3 == val), "" ); - - static_assert ( !(T(1) == o1), "" ); - static_assert ( (T(1) == o2), "" ); - static_assert ( !(T(1) == o3), "" ); - static_assert ( (T(2) == o3), "" ); - static_assert ( (val == o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert(!(o1 == T(1)), ""); + static_assert((o2 == T(1)), ""); + static_assert(!(o3 == T(1)), ""); + static_assert((o3 == T(2)), ""); + static_assert((o3 == val), ""); + + static_assert(!(T(1) == o1), ""); + static_assert((T(1) == o2), ""); + static_assert(!(T(1) == o3), ""); + static_assert((T(2) == o3), ""); + static_assert((val == o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 == 42l, ""); + static_assert(!(101l == o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 == 42, ""); + static_assert(!(101 == o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp index 064114fb9db2..ae34eb20517e 100644 --- a/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp @@ -17,39 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator > ( const X &lhs, const X &rhs ) - { return lhs.i_ > rhs.i_ ; } +constexpr bool operator>(const X& lhs, const X& rhs) { return lhs.i_ > rhs.i_; } -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( !(o1 > T(1)), "" ); - static_assert ( !(o2 > T(1)), "" ); // equal - static_assert ( (o3 > T(1)), "" ); - static_assert ( !(o2 > val), "" ); - static_assert ( !(o3 > val), "" ); // equal - static_assert ( !(o3 > T(3)), "" ); - - static_assert ( (T(1) > o1), "" ); - static_assert ( !(T(1) > o2), "" ); // equal - static_assert ( !(T(1) > o3), "" ); - static_assert ( (val > o2), "" ); - static_assert ( !(val > o3), "" ); // equal - static_assert ( (T(3) > o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert(!(o1 > T(1)), ""); + static_assert(!(o2 > T(1)), ""); // equal + static_assert((o3 > T(1)), ""); + static_assert(!(o2 > val), ""); + static_assert(!(o3 > val), ""); // equal + static_assert(!(o3 > T(3)), ""); + + static_assert((T(1) > o1), ""); + static_assert(!(T(1) > o2), ""); // equal + static_assert(!(T(1) > o3), ""); + static_assert((val > o2), ""); + static_assert(!(val > o3), ""); // equal + static_assert((T(3) > o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 > 11l, ""); + static_assert(!(42l > o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 > 11, ""); + static_assert(!(42 > o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp index 663686cdf347..dac94002661f 100644 --- a/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp @@ -17,39 +17,50 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator >= ( const X &lhs, const X &rhs ) - { return lhs.i_ >= rhs.i_ ; } +constexpr bool operator>=(const X& lhs, const X& rhs) { + return lhs.i_ >= rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( !(o1 >= T(1)), "" ); - static_assert ( (o2 >= T(1)), "" ); // equal - static_assert ( (o3 >= T(1)), "" ); - static_assert ( !(o2 >= val), "" ); - static_assert ( (o3 >= val), "" ); // equal - static_assert ( !(o3 >= T(3)), "" ); - - static_assert ( (T(1) >= o1), "" ); - static_assert ( (T(1) >= o2), "" ); // equal - static_assert ( !(T(1) >= o3), "" ); - static_assert ( (val >= o2), "" ); - static_assert ( (val >= o3), "" ); // equal - static_assert ( (T(3) >= o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert(!(o1 >= T(1)), ""); + static_assert((o2 >= T(1)), ""); // equal + static_assert((o3 >= T(1)), ""); + static_assert(!(o2 >= val), ""); + static_assert((o3 >= val), ""); // equal + static_assert(!(o3 >= T(3)), ""); + + static_assert((T(1) >= o1), ""); + static_assert((T(1) >= o2), ""); // equal + static_assert(!(T(1) >= o3), ""); + static_assert((val >= o2), ""); + static_assert((val >= o3), ""); // equal + static_assert((T(3) >= o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 >= 42l, ""); + static_assert(!(11l >= o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 >= 42, ""); + static_assert(!(11 >= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp index 05ac5eb12b48..b71f8363b0a6 100644 --- a/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp @@ -17,39 +17,50 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator <= ( const X &lhs, const X &rhs ) - { return lhs.i_ <= rhs.i_ ; } +constexpr bool operator<=(const X& lhs, const X& rhs) { + return lhs.i_ <= rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( (o1 <= T(1)), "" ); - static_assert ( (o2 <= T(1)), "" ); // equal - static_assert ( !(o3 <= T(1)), "" ); - static_assert ( (o2 <= val), "" ); - static_assert ( (o3 <= val), "" ); // equal - static_assert ( (o3 <= T(3)), "" ); - - static_assert ( !(T(1) <= o1), "" ); - static_assert ( (T(1) <= o2), "" ); // equal - static_assert ( (T(1) <= o3), "" ); - static_assert ( !(val <= o2), "" ); - static_assert ( (val <= o3), "" ); // equal - static_assert ( !(T(3) <= o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert((o1 <= T(1)), ""); + static_assert((o2 <= T(1)), ""); // equal + static_assert(!(o3 <= T(1)), ""); + static_assert((o2 <= val), ""); + static_assert((o3 <= val), ""); // equal + static_assert((o3 <= T(3)), ""); + + static_assert(!(T(1) <= o1), ""); + static_assert((T(1) <= o2), ""); // equal + static_assert((T(1) <= o3), ""); + static_assert(!(val <= o2), ""); + static_assert((val <= o3), ""); // equal + static_assert(!(T(3) <= o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 <= 42l, ""); + static_assert(!(101l <= o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 <= 42, ""); + static_assert(!(101 <= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp index d1891a286d7b..84456b3baa6e 100644 --- a/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp @@ -17,39 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator < ( const X &lhs, const X &rhs ) - { return lhs.i_ < rhs.i_ ; } +constexpr bool operator<(const X& lhs, const X& rhs) { return lhs.i_ < rhs.i_; } -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( (o1 < T(1)), "" ); - static_assert ( !(o2 < T(1)), "" ); // equal - static_assert ( !(o3 < T(1)), "" ); - static_assert ( (o2 < val), "" ); - static_assert ( !(o3 < val), "" ); // equal - static_assert ( (o3 < T(3)), "" ); - - static_assert ( !(T(1) < o1), "" ); - static_assert ( !(T(1) < o2), "" ); // equal - static_assert ( (T(1) < o3), "" ); - static_assert ( !(val < o2), "" ); - static_assert ( !(val < o3), "" ); // equal - static_assert ( !(T(3) < o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert((o1 < T(1)), ""); + static_assert(!(o2 < T(1)), ""); // equal + static_assert(!(o3 < T(1)), ""); + static_assert((o2 < val), ""); + static_assert(!(o3 < val), ""); // equal + static_assert((o3 < T(3)), ""); + + static_assert(!(T(1) < o1), ""); + static_assert(!(T(1) < o2), ""); // equal + static_assert((T(1) < o3), ""); + static_assert(!(val < o2), ""); + static_assert(!(val < o3), ""); // equal + static_assert(!(T(3) < o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 < 101l, ""); + static_assert(!(42l < o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 < 101, ""); + static_assert(!(42 < o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp index ae2ff808fb25..a4ffdc25e721 100644 --- a/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp @@ -17,37 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator != ( const X &lhs, const X &rhs ) - { return lhs.i_ != rhs.i_ ; } +constexpr bool operator!=(const X& lhs, const X& rhs) { + return lhs.i_ != rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( (o1 != T(1)), "" ); - static_assert ( !(o2 != T(1)), "" ); - static_assert ( (o3 != T(1)), "" ); - static_assert ( !(o3 != T(2)), "" ); - static_assert ( !(o3 != val), "" ); - - static_assert ( (T(1) != o1), "" ); - static_assert ( !(T(1) != o2), "" ); - static_assert ( (T(1) != o3), "" ); - static_assert ( !(T(2) != o3), "" ); - static_assert ( !(val != o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert((o1 != T(1)), ""); + static_assert(!(o2 != T(1)), ""); + static_assert((o3 != T(1)), ""); + static_assert(!(o3 != T(2)), ""); + static_assert(!(o3 != val), ""); + + static_assert((T(1) != o1), ""); + static_assert(!(T(1) != o2), ""); + static_assert((T(1) != o3), ""); + static_assert(!(T(2) != o3), ""); + static_assert(!(val != o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 != 101l, ""); + static_assert(!(42l != o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 != 101, ""); + static_assert(!(42 != o1), ""); + } } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp index 1c90ba76af39..e54a4ced8411 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp +++ b/test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp @@ -7,24 +7,20 @@ // //===----------------------------------------------------------------------===// -// <memory> +// UNSUPPORTED: c++98, c++03, c++11, c++14 -// unique_ptr +// <optional> -// test op->() +// Test that <optional> provides all of the arithmetic, enum, and pointer +// hash specializations. -#include <memory> -#include <cassert> +#include <optional> -struct A -{ - int i_; +#include "poisoned_hash_helper.hpp" - A() : i_(7) {} -}; +int main() { + test_library_hash_specializations_available(); + { -int main() -{ - std::unique_ptr<A[]> p(new A); - assert(p->i_ == 7); + } } diff --git a/test/std/utilities/optional/optional.hash/hash.pass.cpp b/test/std/utilities/optional/optional.hash/hash.pass.cpp index dfdd07ddf452..8c91d6da761e 100644 --- a/test/std/utilities/optional/optional.hash/hash.pass.cpp +++ b/test/std/utilities/optional/optional.hash/hash.pass.cpp @@ -17,6 +17,19 @@ #include <memory> #include <cassert> +#include "poisoned_hash_helper.hpp" + +struct A {}; +struct B {}; + +namespace std { + +template <> +struct hash<B> { + size_t operator()(B const&) noexcept(false) { return 0; } +}; + +} int main() { @@ -27,6 +40,7 @@ int main() { typedef int T; optional<T> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = 2; assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); @@ -34,6 +48,7 @@ int main() { typedef std::string T; optional<T> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = std::string("123"); assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); @@ -41,8 +56,21 @@ int main() { typedef std::unique_ptr<int> T; optional<T> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = std::unique_ptr<int>(new int(3)); assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); } + { + test_hash_enabled_for_type<std::optional<int> >(); + test_hash_enabled_for_type<std::optional<int*> >(); + test_hash_enabled_for_type<std::optional<const int> >(); + test_hash_enabled_for_type<std::optional<int* const> >(); + + test_hash_disabled_for_type<std::optional<A>>(); + test_hash_disabled_for_type<std::optional<const A>>(); + + test_hash_enabled_for_type<std::optional<B>>(); + test_hash_enabled_for_type<std::optional<const B>>(); + } } diff --git a/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp b/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp new file mode 100644 index 000000000000..f9ea7b47911f --- /dev/null +++ b/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// <optional> + +// struct nullopt_t{see below}; +// constexpr nullopt_t nullopt(unspecified); + +// [optional.nullopt]/2: +// Type nullopt_t shall not have a default constructor or an initializer-list constructor. +// It shall not be an aggregate and shall be a literal type. +// Constant nullopt shall be initialized with an argument of literal type. + +#include <optional> +#include "test_macros.h" + +int main() +{ + std::nullopt_t n = {}; +} diff --git a/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp b/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp index 84bb29fabac8..9b752a665a83 100644 --- a/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp +++ b/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp @@ -13,6 +13,11 @@ // struct nullopt_t{see below}; // constexpr nullopt_t nullopt(unspecified); +// [optional.nullopt]/2: +// Type nullopt_t shall not have a default constructor or an initializer-list constructor. +// It shall not be an aggregate and shall be a literal type. +// Constant nullopt shall be initialized with an argument of literal type. + #include <optional> #include <type_traits> @@ -29,9 +34,9 @@ test(const nullopt_t&) int main() { - static_assert((std::is_class<nullopt_t>::value), ""); - static_assert((std::is_empty<nullopt_t>::value), ""); - static_assert((std::is_literal_type<nullopt_t>::value), ""); + static_assert(( std::is_class<nullopt_t>::value), ""); + static_assert(( std::is_empty<nullopt_t>::value), ""); + static_assert(( std::is_literal_type<nullopt_t>::value), ""); static_assert((!std::is_default_constructible<nullopt_t>::value), ""); static_assert(test(nullopt) == 3, ""); diff --git a/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp index 1207e24150ff..0fcc52be1354 100644 --- a/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp +++ b/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp @@ -216,7 +216,6 @@ void test_throws() #ifndef TEST_HAS_NO_EXCEPTIONS using T = ThrowAssign; { - using T = ThrowAssign; optional<T> opt; try { opt = 42; diff --git a/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp index b5362589963c..0696c11526d5 100644 --- a/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp +++ b/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // <optional> -// template <class... Args> void optional<T>::emplace(Args&&... args); +// template <class... Args> T& optional<T>::emplace(Args&&... args); #include <optional> #include <type_traits> @@ -51,27 +51,35 @@ void test_one_arg() { using Opt = std::optional<T>; { Opt opt; - opt.emplace(); + auto & v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(0)); + assert(&v == &*opt); } { Opt opt; - opt.emplace(1); + auto & v = opt.emplace(1); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(1)); + assert(&v == &*opt); } { Opt opt(2); - opt.emplace(); + auto & v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(0)); + assert(&v == &*opt); } { Opt opt(2); - opt.emplace(1); + auto & v = opt.emplace(1); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(1)); + assert(&v == &*opt); } } @@ -83,20 +91,26 @@ void test_multi_arg() using Opt = std::optional<T>; { Opt opt; - opt.emplace(101, 41); + auto &v = opt.emplace(101, 41); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); + assert( v == T(101, 41)); assert(*opt == T(101, 41)); } { Opt opt; - opt.emplace({1, 2, 3, 4}); + auto &v = opt.emplace({1, 2, 3, 4}); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); - assert(*opt == T(4)); // T sets its value to the size of the init list + assert( v == T(4)); // T sets its value to the size of the init list + assert(*opt == T(4)); } { Opt opt; - opt.emplace({1, 2, 3, 4, 5}, 6); + auto &v = opt.emplace({1, 2, 3, 4, 5}, 6); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); + assert( v == T(5)); // T sets its value to the size of the init list assert(*opt == T(5)); // T sets its value to the size of the init list } } @@ -109,73 +123,87 @@ void test_on_test_type() { assert(T::alive == 0); { T::reset_constructors(); - opt.emplace(); + auto &v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::default_constructed == 1); assert(T::destroyed == 0); assert(static_cast<bool>(opt) == true); assert(*opt == T()); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(); + auto &v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::default_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T()); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(101); + auto &v = opt.emplace(101); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(101)); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(-10, 99); + auto &v = opt.emplace(-10, 99); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(-10, 99)); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(-10, 99); + auto &v = opt.emplace(-10, 99); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(-10, 99)); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace({-10, 99, 42, 1}); + auto &v = opt.emplace({-10, 99, 42, 1}); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(4)); // size of the initializer list + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace({-10, 99, 42, 1}, 42); + auto &v = opt.emplace({-10, 99, 42, 1}, 42); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(4)); // size of the initializer list + assert(&v == &*opt); } } @@ -210,8 +238,10 @@ int main() } { optional<const int> opt; - opt.emplace(42); + auto &v = opt.emplace(42); + static_assert( std::is_same_v<const int&, decltype(v)>, "" ); assert(*opt == 42); + assert( v == 42); opt.emplace(); assert(*opt == 0); } diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp index c4d4763a6f0a..d068fbc2db7e 100644 --- a/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp +++ b/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp @@ -35,6 +35,11 @@ struct ExplicitThrow constexpr explicit ExplicitThrow(int x) { if (x != -1) TEST_THROW(6);} }; +struct ImplicitAny { + template <class U> + constexpr ImplicitAny(U&&) {} +}; + template <class To, class From> constexpr bool implicit_conversion(optional<To>&& opt, const From& v) @@ -61,11 +66,9 @@ constexpr bool explicit_conversion(Input&& in, const Expect& v) void test_implicit() { { - using T = long long; static_assert(implicit_conversion<long long>(42, 42), ""); } { - using T = long double; static_assert(implicit_conversion<long double>(3.14, 3.14), ""); } { @@ -81,6 +84,15 @@ void test_implicit() using T = TestTypes::TestType; assert(implicit_conversion<T>(3, T(3))); } + { + using O = optional<ImplicitAny>; + static_assert(!test_convertible<O, std::in_place_t>(), ""); + static_assert(!test_convertible<O, std::in_place_t&>(), ""); + static_assert(!test_convertible<O, const std::in_place_t&>(), ""); + static_assert(!test_convertible<O, std::in_place_t&&>(), ""); + static_assert(!test_convertible<O, const std::in_place_t&&>(), ""); + + } #ifndef TEST_HAS_NO_EXCEPTIONS { try { @@ -97,18 +109,15 @@ void test_implicit() void test_explicit() { { using T = ExplicitTrivialTestTypes::TestType; - using O = optional<T>; static_assert(explicit_conversion<T>(42, 42), ""); } { using T = ExplicitConstexprTestTypes::TestType; - using O = optional<T>; static_assert(explicit_conversion<T>(42, 42), ""); static_assert(!std::is_convertible<int, T>::value, ""); } { using T = ExplicitTestTypes::TestType; - using O = optional<T>; T::reset(); { assert(explicit_conversion<T>(42, 42)); diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp new file mode 100644 index 000000000000..d9e5ca821e85 --- /dev/null +++ b/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// <optional> + +// constexpr optional(const optional<T>& rhs); +// If is_trivially_copy_constructible_v<T> is true, +// this constructor shall be a constexpr constructor. + +#include <optional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct S { + constexpr S() : v_(0) {} + S(int v) : v_(v) {} + S(const S &rhs) : v_(rhs.v_) {} // make it not trivially copyable + int v_; + }; + + +int main() +{ + static_assert (!std::is_trivially_copy_constructible_v<S>, "" ); + constexpr std::optional<S> o1; + constexpr std::optional<S> o2 = o1; // not constexpr +} diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp new file mode 100644 index 000000000000..c7458d95abfd --- /dev/null +++ b/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// <optional> + +// constexpr optional(const optional<T>&& rhs); +// If is_trivially_move_constructible_v<T> is true, +// this constructor shall be a constexpr constructor. + +#include <optional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct S { + constexpr S() : v_(0) {} + S(int v) : v_(v) {} + constexpr S(const S &rhs) : v_(rhs.v_) {} // not trivially moveable + constexpr S(const S &&rhs) : v_(rhs.v_) {} // not trivially moveable + int v_; + }; + + +int main() +{ + static_assert (!std::is_trivially_move_constructible_v<S>, "" ); + constexpr std::optional<S> o1; + constexpr std::optional<S> o2 = std::move(o1); // not constexpr +} diff --git a/test/std/utilities/optional/optional.relops/equal.pass.cpp b/test/std/utilities/optional/optional.relops/equal.pass.cpp index 6650b6720a8e..7667540f9760 100644 --- a/test/std/utilities/optional/optional.relops/equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/equal.pass.cpp @@ -18,57 +18,69 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator == ( const X &lhs, const X &rhs ) - { return lhs.i_ == rhs.i_ ; } +constexpr bool operator==(const X& lhs, const X& rhs) { + return lhs.i_ == rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged - - static_assert ( o1 == o1 , "" ); - static_assert ( o1 == o2 , "" ); - static_assert ( !(o1 == o3), "" ); - static_assert ( !(o1 == o4), "" ); - static_assert ( !(o1 == o5), "" ); + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( o2 == o1 , "" ); - static_assert ( o2 == o2 , "" ); - static_assert ( !(o2 == o3), "" ); - static_assert ( !(o2 == o4), "" ); - static_assert ( !(o2 == o5), "" ); + static_assert(o1 == o1, ""); + static_assert(o1 == o2, ""); + static_assert(!(o1 == o3), ""); + static_assert(!(o1 == o4), ""); + static_assert(!(o1 == o5), ""); - static_assert ( !(o3 == o1), "" ); - static_assert ( !(o3 == o2), "" ); - static_assert ( o3 == o3 , "" ); - static_assert ( !(o3 == o4), "" ); - static_assert ( o3 == o5 , "" ); + static_assert(o2 == o1, ""); + static_assert(o2 == o2, ""); + static_assert(!(o2 == o3), ""); + static_assert(!(o2 == o4), ""); + static_assert(!(o2 == o5), ""); - static_assert ( !(o4 == o1), "" ); - static_assert ( !(o4 == o2), "" ); - static_assert ( !(o4 == o3), "" ); - static_assert ( o4 == o4 , "" ); - static_assert ( !(o4 == o5), "" ); + static_assert(!(o3 == o1), ""); + static_assert(!(o3 == o2), ""); + static_assert(o3 == o3, ""); + static_assert(!(o3 == o4), ""); + static_assert(o3 == o5, ""); - static_assert ( !(o5 == o1), "" ); - static_assert ( !(o5 == o2), "" ); - static_assert ( o5 == o3 , "" ); - static_assert ( !(o5 == o4), "" ); - static_assert ( o5 == o5 , "" ); + static_assert(!(o4 == o1), ""); + static_assert(!(o4 == o2), ""); + static_assert(!(o4 == o3), ""); + static_assert(o4 == o4, ""); + static_assert(!(o4 == o5), ""); - } + static_assert(!(o5 == o1), ""); + static_assert(!(o5 == o2), ""); + static_assert(o5 == o3, ""); + static_assert(!(o5 == o4), ""); + static_assert(o5 == o5, ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 == O2(42), ""); + static_assert(!(O2(101) == o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 == O2(42), ""); + static_assert(!(O2(101) == o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp b/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp index f9b30449638a..0e05834c147a 100644 --- a/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp @@ -16,55 +16,68 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator >= ( const X &lhs, const X &rhs ) - { return lhs.i_ >= rhs.i_ ; } +constexpr bool operator>=(const X& lhs, const X& rhs) { + return lhs.i_ >= rhs.i_; +} -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( (o1 >= o1), "" ); - static_assert ( (o1 >= o2), "" ); - static_assert ( !(o1 >= o3), "" ); - static_assert ( !(o1 >= o4), "" ); - static_assert ( !(o1 >= o5), "" ); + static_assert((o1 >= o1), ""); + static_assert((o1 >= o2), ""); + static_assert(!(o1 >= o3), ""); + static_assert(!(o1 >= o4), ""); + static_assert(!(o1 >= o5), ""); - static_assert ( (o2 >= o1), "" ); - static_assert ( (o2 >= o2), "" ); - static_assert ( !(o2 >= o3), "" ); - static_assert ( !(o2 >= o4), "" ); - static_assert ( !(o2 >= o5), "" ); + static_assert((o2 >= o1), ""); + static_assert((o2 >= o2), ""); + static_assert(!(o2 >= o3), ""); + static_assert(!(o2 >= o4), ""); + static_assert(!(o2 >= o5), ""); - static_assert ( (o3 >= o1), "" ); - static_assert ( (o3 >= o2), "" ); - static_assert ( (o3 >= o3), "" ); - static_assert ( !(o3 >= o4), "" ); - static_assert ( (o3 >= o5), "" ); + static_assert((o3 >= o1), ""); + static_assert((o3 >= o2), ""); + static_assert((o3 >= o3), ""); + static_assert(!(o3 >= o4), ""); + static_assert((o3 >= o5), ""); - static_assert ( (o4 >= o1), "" ); - static_assert ( (o4 >= o2), "" ); - static_assert ( (o4 >= o3), "" ); - static_assert ( (o4 >= o4), "" ); - static_assert ( (o4 >= o5), "" ); + static_assert((o4 >= o1), ""); + static_assert((o4 >= o2), ""); + static_assert((o4 >= o3), ""); + static_assert((o4 >= o4), ""); + static_assert((o4 >= o5), ""); - static_assert ( (o5 >= o1), "" ); - static_assert ( (o5 >= o2), "" ); - static_assert ( (o5 >= o3), "" ); - static_assert ( !(o5 >= o4), "" ); - static_assert ( (o5 >= o5), "" ); - } + static_assert((o5 >= o1), ""); + static_assert((o5 >= o2), ""); + static_assert((o5 >= o3), ""); + static_assert(!(o5 >= o4), ""); + static_assert((o5 >= o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 >= O2(42), ""); + static_assert(!(O2(11) >= o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 >= O2(42), ""); + static_assert(!(O2(1) >= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/greater_than.pass.cpp b/test/std/utilities/optional/optional.relops/greater_than.pass.cpp index 8a27eb471f28..3946a6102ba9 100644 --- a/test/std/utilities/optional/optional.relops/greater_than.pass.cpp +++ b/test/std/utilities/optional/optional.relops/greater_than.pass.cpp @@ -16,55 +16,66 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator > ( const X &lhs, const X &rhs ) - { return lhs.i_ > rhs.i_ ; } +constexpr bool operator>(const X& lhs, const X& rhs) { return lhs.i_ > rhs.i_; } -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( !(o1 > o1), "" ); - static_assert ( !(o1 > o2), "" ); - static_assert ( !(o1 > o3), "" ); - static_assert ( !(o1 > o4), "" ); - static_assert ( !(o1 > o5), "" ); + static_assert(!(o1 > o1), ""); + static_assert(!(o1 > o2), ""); + static_assert(!(o1 > o3), ""); + static_assert(!(o1 > o4), ""); + static_assert(!(o1 > o5), ""); - static_assert ( !(o2 > o1), "" ); - static_assert ( !(o2 > o2), "" ); - static_assert ( !(o2 > o3), "" ); - static_assert ( !(o2 > o4), "" ); - static_assert ( !(o2 > o5), "" ); + static_assert(!(o2 > o1), ""); + static_assert(!(o2 > o2), ""); + static_assert(!(o2 > o3), ""); + static_assert(!(o2 > o4), ""); + static_assert(!(o2 > o5), ""); - static_assert ( (o3 > o1), "" ); - static_assert ( (o3 > o2), "" ); - static_assert ( !(o3 > o3), "" ); - static_assert ( !(o3 > o4), "" ); - static_assert ( !(o3 > o5), "" ); + static_assert((o3 > o1), ""); + static_assert((o3 > o2), ""); + static_assert(!(o3 > o3), ""); + static_assert(!(o3 > o4), ""); + static_assert(!(o3 > o5), ""); - static_assert ( (o4 > o1), "" ); - static_assert ( (o4 > o2), "" ); - static_assert ( (o4 > o3), "" ); - static_assert ( !(o4 > o4), "" ); - static_assert ( (o4 > o5), "" ); + static_assert((o4 > o1), ""); + static_assert((o4 > o2), ""); + static_assert((o4 > o3), ""); + static_assert(!(o4 > o4), ""); + static_assert((o4 > o5), ""); - static_assert ( (o5 > o1), "" ); - static_assert ( (o5 > o2), "" ); - static_assert ( !(o5 > o3), "" ); - static_assert ( !(o5 > o4), "" ); - static_assert ( !(o5 > o5), "" ); - } + static_assert((o5 > o1), ""); + static_assert((o5 > o2), ""); + static_assert(!(o5 > o3), ""); + static_assert(!(o5 > o4), ""); + static_assert(!(o5 > o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 > O2(1), ""); + static_assert(!(O2(42) > o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 > O2(1), ""); + static_assert(!(O2(42) > o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/less_equal.pass.cpp b/test/std/utilities/optional/optional.relops/less_equal.pass.cpp index a7d594dd34a2..5a1954154f44 100644 --- a/test/std/utilities/optional/optional.relops/less_equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/less_equal.pass.cpp @@ -16,55 +16,68 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator <= ( const X &lhs, const X &rhs ) - { return lhs.i_ <= rhs.i_ ; } +constexpr bool operator<=(const X& lhs, const X& rhs) { + return lhs.i_ <= rhs.i_; +} -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( (o1 <= o1), "" ); - static_assert ( (o1 <= o2), "" ); - static_assert ( (o1 <= o3), "" ); - static_assert ( (o1 <= o4), "" ); - static_assert ( (o1 <= o5), "" ); + static_assert((o1 <= o1), ""); + static_assert((o1 <= o2), ""); + static_assert((o1 <= o3), ""); + static_assert((o1 <= o4), ""); + static_assert((o1 <= o5), ""); - static_assert ( (o2 <= o1), "" ); - static_assert ( (o2 <= o2), "" ); - static_assert ( (o2 <= o3), "" ); - static_assert ( (o2 <= o4), "" ); - static_assert ( (o2 <= o5), "" ); + static_assert((o2 <= o1), ""); + static_assert((o2 <= o2), ""); + static_assert((o2 <= o3), ""); + static_assert((o2 <= o4), ""); + static_assert((o2 <= o5), ""); - static_assert ( !(o3 <= o1), "" ); - static_assert ( !(o3 <= o2), "" ); - static_assert ( (o3 <= o3), "" ); - static_assert ( (o3 <= o4), "" ); - static_assert ( (o3 <= o5), "" ); + static_assert(!(o3 <= o1), ""); + static_assert(!(o3 <= o2), ""); + static_assert((o3 <= o3), ""); + static_assert((o3 <= o4), ""); + static_assert((o3 <= o5), ""); - static_assert ( !(o4 <= o1), "" ); - static_assert ( !(o4 <= o2), "" ); - static_assert ( !(o4 <= o3), "" ); - static_assert ( (o4 <= o4), "" ); - static_assert ( !(o4 <= o5), "" ); + static_assert(!(o4 <= o1), ""); + static_assert(!(o4 <= o2), ""); + static_assert(!(o4 <= o3), ""); + static_assert((o4 <= o4), ""); + static_assert(!(o4 <= o5), ""); - static_assert ( !(o5 <= o1), "" ); - static_assert ( !(o5 <= o2), "" ); - static_assert ( (o5 <= o3), "" ); - static_assert ( (o5 <= o4), "" ); - static_assert ( (o5 <= o5), "" ); - } + static_assert(!(o5 <= o1), ""); + static_assert(!(o5 <= o2), ""); + static_assert((o5 <= o3), ""); + static_assert((o5 <= o4), ""); + static_assert((o5 <= o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 <= O2(42), ""); + static_assert(!(O2(101) <= o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 <= O2(42), ""); + static_assert(!(O2(101) <= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/less_than.pass.cpp b/test/std/utilities/optional/optional.relops/less_than.pass.cpp index deffa5e849f9..35956e6f4a70 100644 --- a/test/std/utilities/optional/optional.relops/less_than.pass.cpp +++ b/test/std/utilities/optional/optional.relops/less_than.pass.cpp @@ -16,55 +16,66 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator < ( const X &lhs, const X &rhs ) - { return lhs.i_ < rhs.i_ ; } +constexpr bool operator<(const X& lhs, const X& rhs) { return lhs.i_ < rhs.i_; } -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( !(o1 < o1), "" ); - static_assert ( !(o1 < o2), "" ); - static_assert ( (o1 < o3), "" ); - static_assert ( (o1 < o4), "" ); - static_assert ( (o1 < o5), "" ); + static_assert(!(o1 < o1), ""); + static_assert(!(o1 < o2), ""); + static_assert((o1 < o3), ""); + static_assert((o1 < o4), ""); + static_assert((o1 < o5), ""); - static_assert ( !(o2 < o1), "" ); - static_assert ( !(o2 < o2), "" ); - static_assert ( (o2 < o3), "" ); - static_assert ( (o2 < o4), "" ); - static_assert ( (o2 < o5), "" ); + static_assert(!(o2 < o1), ""); + static_assert(!(o2 < o2), ""); + static_assert((o2 < o3), ""); + static_assert((o2 < o4), ""); + static_assert((o2 < o5), ""); - static_assert ( !(o3 < o1), "" ); - static_assert ( !(o3 < o2), "" ); - static_assert ( !(o3 < o3), "" ); - static_assert ( (o3 < o4), "" ); - static_assert ( !(o3 < o5), "" ); + static_assert(!(o3 < o1), ""); + static_assert(!(o3 < o2), ""); + static_assert(!(o3 < o3), ""); + static_assert((o3 < o4), ""); + static_assert(!(o3 < o5), ""); - static_assert ( !(o4 < o1), "" ); - static_assert ( !(o4 < o2), "" ); - static_assert ( !(o4 < o3), "" ); - static_assert ( !(o4 < o4), "" ); - static_assert ( !(o4 < o5), "" ); + static_assert(!(o4 < o1), ""); + static_assert(!(o4 < o2), ""); + static_assert(!(o4 < o3), ""); + static_assert(!(o4 < o4), ""); + static_assert(!(o4 < o5), ""); - static_assert ( !(o5 < o1), "" ); - static_assert ( !(o5 < o2), "" ); - static_assert ( !(o5 < o3), "" ); - static_assert ( (o5 < o4), "" ); - static_assert ( !(o5 < o5), "" ); - } + static_assert(!(o5 < o1), ""); + static_assert(!(o5 < o2), ""); + static_assert(!(o5 < o3), ""); + static_assert((o5 < o4), ""); + static_assert(!(o5 < o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 < O2(101), ""); + static_assert(!(O2(101) < o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 < O2(101), ""); + static_assert(!(O2(101) < o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/not_equal.pass.cpp b/test/std/utilities/optional/optional.relops/not_equal.pass.cpp index fd11b2a207ca..1256537d6a86 100644 --- a/test/std/utilities/optional/optional.relops/not_equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/not_equal.pass.cpp @@ -18,57 +18,69 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator != ( const X &lhs, const X &rhs ) - { return lhs.i_ != rhs.i_ ; } +constexpr bool operator!=(const X& lhs, const X& rhs) { + return lhs.i_ != rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged - - static_assert ( !(o1 != o1), "" ); - static_assert ( !(o1 != o2), "" ); - static_assert ( (o1 != o3), "" ); - static_assert ( (o1 != o4), "" ); - static_assert ( (o1 != o5), "" ); + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( !(o2 != o1), "" ); - static_assert ( !(o2 != o2), "" ); - static_assert ( (o2 != o3), "" ); - static_assert ( (o2 != o4), "" ); - static_assert ( (o2 != o5), "" ); + static_assert(!(o1 != o1), ""); + static_assert(!(o1 != o2), ""); + static_assert((o1 != o3), ""); + static_assert((o1 != o4), ""); + static_assert((o1 != o5), ""); - static_assert ( (o3 != o1), "" ); - static_assert ( (o3 != o2), "" ); - static_assert ( !(o3 != o3), "" ); - static_assert ( (o3 != o4), "" ); - static_assert ( !(o3 != o5), "" ); + static_assert(!(o2 != o1), ""); + static_assert(!(o2 != o2), ""); + static_assert((o2 != o3), ""); + static_assert((o2 != o4), ""); + static_assert((o2 != o5), ""); - static_assert ( (o4 != o1), "" ); - static_assert ( (o4 != o2), "" ); - static_assert ( (o4 != o3), "" ); - static_assert ( !(o4 != o4), "" ); - static_assert ( (o4 != o5), "" ); + static_assert((o3 != o1), ""); + static_assert((o3 != o2), ""); + static_assert(!(o3 != o3), ""); + static_assert((o3 != o4), ""); + static_assert(!(o3 != o5), ""); - static_assert ( (o5 != o1), "" ); - static_assert ( (o5 != o2), "" ); - static_assert ( !(o5 != o3), "" ); - static_assert ( (o5 != o4), "" ); - static_assert ( !(o5 != o5), "" ); + static_assert((o4 != o1), ""); + static_assert((o4 != o2), ""); + static_assert((o4 != o3), ""); + static_assert(!(o4 != o4), ""); + static_assert((o4 != o5), ""); - } + static_assert((o5 != o1), ""); + static_assert((o5 != o2), ""); + static_assert(!(o5 != o3), ""); + static_assert((o5 != o4), ""); + static_assert(!(o5 != o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 != O2(101), ""); + static_assert(!(O2(42) != o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 != O2(101), ""); + static_assert(!(O2(42) != o1), ""); + } } diff --git a/test/std/utilities/smartptr/unique.ptr/README.TXT b/test/std/utilities/smartptr/unique.ptr/README.TXT new file mode 100644 index 000000000000..20f77f61827c --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/README.TXT @@ -0,0 +1,16 @@ +Test Naming and Directory Structure +=================================== + +The directory structure for the unique_ptr class templates differs from the +normal test directory naming conventions (e.g. matching the stable name in the standard). + +Instead of having a [unique.ptr.single] and [unique.ptr.runtime] directory, +each containing their own tests, a single directory, "unique.ptr.class", +contains both sets of tests. + +This allows the common behavior of the two unique_ptr specializations to be +tested in the same place without duplication. + +Tests specific to [unique.ptr.single] have the suffix ".single.pass.cpp" +and those specific to [unique.ptr.runtime] are named "*.runtime.pass.cpp". +Tests for both specializations are named normally. diff --git a/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp index b58f5c55b643..b58f5c55b643 100644 --- a/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp new file mode 100644 index 000000000000..54c2cf16ecc7 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// Test unique_ptr::pointer type + +#include <memory> +#include <type_traits> + +#include "test_macros.h" + +struct Deleter { + struct pointer {}; +}; + +struct D2 { +private: + typedef void pointer; +}; + +struct D3 { + static long pointer; +}; + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + { + typedef std::unique_ptr<VT> P; + static_assert((std::is_same<typename P::pointer, int*>::value), ""); + } + { + typedef std::unique_ptr<VT, Deleter> P; + static_assert((std::is_same<typename P::pointer, Deleter::pointer>::value), + ""); + } +#if TEST_STD_VER >= 11 + { + typedef std::unique_ptr<VT, D2> P; + static_assert(std::is_same<typename P::pointer, int*>::value, ""); + } + { + typedef std::unique_ptr<VT, D3> P; + static_assert(std::is_same<typename P::pointer, int*>::value, ""); + } +#endif +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp new file mode 100644 index 000000000000..5d2f955aa185 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp @@ -0,0 +1,120 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// Test unique_ptr move assignment + +// test move assignment. Should only require a MoveConstructible deleter, or if +// deleter is a reference, not even that. + +#include <memory> +#include <utility> +#include <cassert> + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +struct GenericDeleter { + void operator()(void*) const; +}; + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr<VT> s1(newValue<VT>(expect_alive)); + A* p = s1.get(); + std::unique_ptr<VT> s2(newValue<VT>(expect_alive)); + assert(A::count == (expect_alive * 2)); + s2 = std::move(s1); + assert(A::count == expect_alive); + assert(s2.get() == p); + assert(s1.get() == 0); + } + assert(A::count == 0); + { + std::unique_ptr<VT, Deleter<VT> > s1(newValue<VT>(expect_alive), + Deleter<VT>(5)); + A* p = s1.get(); + std::unique_ptr<VT, Deleter<VT> > s2(newValue<VT>(expect_alive)); + assert(A::count == (expect_alive * 2)); + s2 = std::move(s1); + assert(s2.get() == p); + assert(s1.get() == 0); + assert(A::count == expect_alive); + assert(s2.get_deleter().state() == 5); + assert(s1.get_deleter().state() == 0); + } + assert(A::count == 0); + { + CDeleter<VT> d1(5); + std::unique_ptr<VT, CDeleter<VT>&> s1(newValue<VT>(expect_alive), d1); + A* p = s1.get(); + CDeleter<VT> d2(6); + std::unique_ptr<VT, CDeleter<VT>&> s2(newValue<VT>(expect_alive), d2); + s2 = std::move(s1); + assert(s2.get() == p); + assert(s1.get() == 0); + assert(A::count == expect_alive); + assert(d1.state() == 5); + assert(d2.state() == 5); + } + assert(A::count == 0); +} + +template <bool IsArray> +void test_sfinae() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + { + typedef std::unique_ptr<VT> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } + { + typedef std::unique_ptr<VT, GenericDeleter> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } + { + typedef std::unique_ptr<VT, NCDeleter<VT>&> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } + { + typedef std::unique_ptr<VT, const NCDeleter<VT>&> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } +} + + +int main() { + { + test_basic</*IsArray*/ false>(); + test_sfinae<false>(); + } + { + test_basic</*IsArray*/ true>(); + test_sfinae<true>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.pass.cpp new file mode 100644 index 000000000000..8d83c3c8888a --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.pass.cpp @@ -0,0 +1,420 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" +#include "type_id.h" + +template <int ID = 0> +struct GenericDeleter { + void operator()(void*) const {} +}; + +template <int ID = 0> +struct GenericConvertingDeleter { + + template <int OID> + GenericConvertingDeleter(GenericConvertingDeleter<OID>) {} + + template <int OID> + GenericConvertingDeleter& operator=(GenericConvertingDeleter<OID> const&) { + return *this; + } + + void operator()(void*) const {} +}; + +template <class T, class U> +using EnableIfNotSame = typename std::enable_if< + !std::is_same<typename std::decay<T>::type, typename std::decay<U>::type>::value +>::type; + +template <class Templ, class Other> +struct is_specialization; + +template <template <int> class Templ, int ID1, class Other> +struct is_specialization<Templ<ID1>, Other> : std::false_type {}; + +template <template <int> class Templ, int ID1, int ID2> +struct is_specialization<Templ<ID1>, Templ<ID2> > : std::true_type {}; + +template <class Templ, class Other> +using EnableIfSpecialization = typename std::enable_if< + is_specialization<Templ, typename std::decay<Other>::type >::value + >::type; + +template <int ID> struct TrackingDeleter; +template <int ID> struct ConstTrackingDeleter; + +template <int ID> +struct TrackingDeleter { + TrackingDeleter() : arg_type(&makeArgumentID<>()) {} + + TrackingDeleter(TrackingDeleter const&) + : arg_type(&makeArgumentID<TrackingDeleter const&>()) {} + + TrackingDeleter(TrackingDeleter&&) + : arg_type(&makeArgumentID<TrackingDeleter &&>()) {} + + template <class T, class = EnableIfSpecialization<TrackingDeleter, T> > + TrackingDeleter(T&&) : arg_type(&makeArgumentID<T&&>()) {} + + TrackingDeleter& operator=(TrackingDeleter const&) { + arg_type = &makeArgumentID<TrackingDeleter const&>(); + return *this; + } + + TrackingDeleter& operator=(TrackingDeleter &&) { + arg_type = &makeArgumentID<TrackingDeleter &&>(); + return *this; + } + + template <class T, class = EnableIfSpecialization<TrackingDeleter, T> > + TrackingDeleter& operator=(T&&) { + arg_type = &makeArgumentID<T&&>(); + return *this; + } + + void operator()(void*) const {} + +public: + TypeID const* reset() const { + TypeID const* tmp = arg_type; + arg_type = nullptr; + return tmp; + } + + mutable TypeID const* arg_type; +}; + +template <int ID> +struct ConstTrackingDeleter { + ConstTrackingDeleter() : arg_type(&makeArgumentID<>()) {} + + ConstTrackingDeleter(ConstTrackingDeleter const&) + : arg_type(&makeArgumentID<ConstTrackingDeleter const&>()) {} + + ConstTrackingDeleter(ConstTrackingDeleter&&) + : arg_type(&makeArgumentID<ConstTrackingDeleter &&>()) {} + + template <class T, class = EnableIfSpecialization<ConstTrackingDeleter, T> > + ConstTrackingDeleter(T&&) : arg_type(&makeArgumentID<T&&>()) {} + + const ConstTrackingDeleter& operator=(ConstTrackingDeleter const&) const { + arg_type = &makeArgumentID<ConstTrackingDeleter const&>(); + return *this; + } + + const ConstTrackingDeleter& operator=(ConstTrackingDeleter &&) const { + arg_type = &makeArgumentID<ConstTrackingDeleter &&>(); + return *this; + } + + template <class T, class = EnableIfSpecialization<ConstTrackingDeleter, T> > + const ConstTrackingDeleter& operator=(T&&) const { + arg_type = &makeArgumentID<T&&>(); + return *this; + } + + void operator()(void*) const {} + +public: + TypeID const* reset() const { + TypeID const* tmp = arg_type; + arg_type = nullptr; + return tmp; + } + + mutable TypeID const* arg_type; +}; + +template <class ExpectT, int ID> +bool checkArg(TrackingDeleter<ID> const& d) { + return d.arg_type && *d.arg_type == makeArgumentID<ExpectT>(); +} + +template <class ExpectT, int ID> +bool checkArg(ConstTrackingDeleter<ID> const& d) { + return d.arg_type && *d.arg_type == makeArgumentID<ExpectT>(); +} + +template <class From, bool AssignIsConst = false> +struct AssignDeleter { + AssignDeleter() = default; + AssignDeleter(AssignDeleter const&) = default; + AssignDeleter(AssignDeleter&&) = default; + + AssignDeleter& operator=(AssignDeleter const&) = delete; + AssignDeleter& operator=(AssignDeleter &&) = delete; + + template <class T> AssignDeleter& operator=(T&&) && = delete; + template <class T> AssignDeleter& operator=(T&&) const && = delete; + + template <class T, class = typename std::enable_if< + std::is_same<T&&, From>::value && !AssignIsConst + >::type> + AssignDeleter& operator=(T&&) & { return *this; } + + template <class T, class = typename std::enable_if< + std::is_same<T&&, From>::value && AssignIsConst + >::type> + const AssignDeleter& operator=(T&&) const & { return *this; } + + template <class T> + void operator()(T) const {} +}; + +template <class VT, class DDest, class DSource> + void doDeleterTest() { + using U1 = std::unique_ptr<VT, DDest>; + using U2 = std::unique_ptr<VT, DSource>; + static_assert(std::is_nothrow_assignable<U1, U2&&>::value, ""); + typename std::decay<DDest>::type ddest; + typename std::decay<DSource>::type dsource; + U1 u1(nullptr, ddest); + U2 u2(nullptr, dsource); + u1 = std::move(u2); +} + +template <bool IsArray> +void test_sfinae() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + + { // Test that different non-reference deleter types are allowed so long + // as they convert to each other. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + static_assert(std::is_assignable<U1, U2&&>::value, ""); + } + { // Test that different non-reference deleter types are disallowed when + // they cannot convert. + using U1 = std::unique_ptr<VT, GenericDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericDeleter<1> >; + static_assert(!std::is_assignable<U1, U2&&>::value, ""); + } + { // Test that if the deleter assignment is not valid the assignment operator + // SFINAEs. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> const& >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(!std::is_assignable<U1, U2&&>::value, ""); + static_assert(!std::is_assignable<U1, U3&&>::value, ""); + static_assert(!std::is_assignable<U1, U4&&>::value, ""); + static_assert(!std::is_assignable<U1, U5&&>::value, ""); + + using U1C = std::unique_ptr<const VT, GenericConvertingDeleter<0> const&>; + static_assert(std::is_nothrow_assignable<U1C, U1&&>::value, ""); + } + { // Test that if the deleter assignment is not valid the assignment operator + // SFINAEs. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> & >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + + static_assert(std::is_nothrow_assignable<U1, U2&&>::value, ""); + static_assert(std::is_nothrow_assignable<U1, U3&&>::value, ""); + static_assert(std::is_nothrow_assignable<U1, U4&&>::value, ""); + static_assert(std::is_nothrow_assignable<U1, U5&&>::value, ""); + + using U1C = std::unique_ptr<const VT, GenericConvertingDeleter<0> &>; + static_assert(std::is_nothrow_assignable<U1C, U1&&>::value, ""); + } + { // Test that non-reference destination deleters can be assigned + // from any source deleter type with a sutible conversion. Including + // reference types. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> const &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> &>; + using U6 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(std::is_assignable<U1, U2&&>::value, ""); + static_assert(std::is_assignable<U1, U3&&>::value, ""); + static_assert(std::is_assignable<U1, U4&&>::value, ""); + static_assert(std::is_assignable<U1, U5&&>::value, ""); + static_assert(std::is_assignable<U1, U6&&>::value, ""); + } + ///////////////////////////////////////////////////////////////////////////// + { + using Del = GenericDeleter<0>; + using AD = AssignDeleter<Del&&>; + using ADC = AssignDeleter<Del&&, /*AllowConstAssign*/true>; + doDeleterTest<VT, AD, Del>(); + doDeleterTest<VT, AD&, Del>(); + doDeleterTest<VT, ADC const&, Del>(); + } + { + using Del = GenericDeleter<0>; + using AD = AssignDeleter<Del&>; + using ADC = AssignDeleter<Del&, /*AllowConstAssign*/true>; + doDeleterTest<VT, AD, Del&>(); + doDeleterTest<VT, AD&, Del&>(); + doDeleterTest<VT, ADC const&, Del&>(); + } + { + using Del = GenericDeleter<0>; + using AD = AssignDeleter<Del const&>; + using ADC = AssignDeleter<Del const&, /*AllowConstAssign*/true>; + doDeleterTest<VT, AD, Del const&>(); + doDeleterTest<VT, AD&, Del const&>(); + doDeleterTest<VT, ADC const&, Del const&>(); + } +} + + +template <bool IsArray> +void test_noexcept() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + { + typedef std::unique_ptr<const VT> APtr; + typedef std::unique_ptr<VT> BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, CDeleter<const VT> > APtr; + typedef std::unique_ptr<VT, CDeleter<VT> > BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, NCDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, NCDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, const NCConstDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, const NCConstDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } +} + +template <bool IsArray> +void test_deleter_value_category() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + using TD1 = TrackingDeleter<1>; + using TD2 = TrackingDeleter<2>; + TD1 d1; + TD2 d2; + using CD1 = ConstTrackingDeleter<1>; + using CD2 = ConstTrackingDeleter<2>; + CD1 cd1; + CD2 cd2; + + { // Test non-reference deleter conversions + using U1 = std::unique_ptr<VT, TD1 >; + using U2 = std::unique_ptr<VT, TD2 >; + U1 u1; + U2 u2; + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&&>(u1.get_deleter())); + } + { // Test assignment to non-const ref + using U1 = std::unique_ptr<VT, TD1& >; + using U2 = std::unique_ptr<VT, TD2 >; + U1 u1(nullptr, d1); + U2 u2; + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&&>(u1.get_deleter())); + } + { // Test assignment to const&. + using U1 = std::unique_ptr<VT, CD1 const& >; + using U2 = std::unique_ptr<VT, CD2 >; + U1 u1(nullptr, cd1); + U2 u2; + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<CD2&&>(u1.get_deleter())); + } + + { // Test assignment from non-const ref + using U1 = std::unique_ptr<VT, TD1 >; + using U2 = std::unique_ptr<VT, TD2& >; + U1 u1; + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&>(u1.get_deleter())); + } + { // Test assignment from const ref + using U1 = std::unique_ptr<VT, TD1 >; + using U2 = std::unique_ptr<VT, TD2 const& >; + U1 u1; + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2 const&>(u1.get_deleter())); + } + + { // Test assignment from non-const ref + using U1 = std::unique_ptr<VT, TD1& >; + using U2 = std::unique_ptr<VT, TD2& >; + U1 u1(nullptr, d1); + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&>(u1.get_deleter())); + } + { // Test assignment from const ref + using U1 = std::unique_ptr<VT, TD1& >; + using U2 = std::unique_ptr<VT, TD2 const& >; + U1 u1(nullptr, d1); + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2 const&>(u1.get_deleter())); + } + + { // Test assignment from non-const ref + using U1 = std::unique_ptr<VT, CD1 const& >; + using U2 = std::unique_ptr<VT, CD2 & >; + U1 u1(nullptr, cd1); + U2 u2(nullptr, cd2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<CD2 &>(u1.get_deleter())); + } + { // Test assignment from const ref + using U1 = std::unique_ptr<VT, CD1 const& >; + using U2 = std::unique_ptr<VT, CD2 const& >; + U1 u1(nullptr, cd1); + U2 u2(nullptr, cd2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<CD2 const&>(u1.get_deleter())); + } +} + +int main() { + { + test_sfinae</*IsArray*/false>(); + test_noexcept<false>(); + test_deleter_value_category<false>(); + } + { + test_sfinae</*IsArray*/true>(); + test_noexcept<true>(); + test_deleter_value_category<true>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp new file mode 100644 index 000000000000..9b946a733fea --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include <memory> +#include <utility> +#include <cassert> + +#include "unique_ptr_test_helper.h" + +template <class APtr, class BPtr> +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template <class LHS, class RHS> +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +template <class T> +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +template <class T> +struct NCConvertingDeleter<T[]> { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +struct GenericDeleter { + void operator()(void*) const; +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter<A[]>; // non-copyable deleters + using DAC = NCConvertingDeleter<const A[]>; // non-copyable deleters + + using DB = NCConvertingDeleter<B[]>; + using UA = std::unique_ptr<A[]>; + using UAC = std::unique_ptr<const A[]>; + using UB = std::unique_ptr<B[]>; + using UAD = std::unique_ptr<A[], DA>; + using UACD = std::unique_ptr<const A[], DAC>; + + using UBD = std::unique_ptr<B[], DB>; + { // cannot move from an lvalue + static_assert(std::is_assignable<UAC, UA&&>::value, ""); + static_assert(!std::is_assignable<UAC, UA&>::value, ""); + static_assert(!std::is_assignable<UAC, const UA&>::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_assignable<UACD, UAD&&>::value, ""); + static_assert(!std::is_assignable<UACD, UAC&&>::value, ""); + static_assert(!std::is_assignable<UAC, UACD&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A[], DA&>; + using UA2 = std::unique_ptr<A[], DAC&>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A[], const DA&>; + using UA2 = std::unique_ptr<A[], const DAC&>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Single> + using UA1 = std::unique_ptr<A[]>; + using UA2 = std::unique_ptr<A>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A[], NCGenericDeleter>; + using UA2 = std::unique_ptr<A, NCGenericDeleter>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } +} + +int main() { + test_sfinae(); + // FIXME: add tests +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp new file mode 100644 index 000000000000..3f2ea422dab3 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp @@ -0,0 +1,145 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include <memory> +#include <utility> +#include <cassert> + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +template <class APtr, class BPtr> +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template <class LHS, class RHS> +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +template <class T> +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +template <class T> +struct NCConvertingDeleter<T[]> { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter<A>; // non-copyable deleters + using DB = NCConvertingDeleter<B>; + using UA = std::unique_ptr<A>; + using UB = std::unique_ptr<B>; + using UAD = std::unique_ptr<A, DA>; + using UBD = std::unique_ptr<B, DB>; + { // cannot move from an lvalue + static_assert(std::is_assignable<UA, UB&&>::value, ""); + static_assert(!std::is_assignable<UA, UB&>::value, ""); + static_assert(!std::is_assignable<UA, const UB&>::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_assignable<UAD, UBD&&>::value, ""); + static_assert(!std::is_assignable<UAD, UB&&>::value, ""); + static_assert(!std::is_assignable<UA, UBD&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, DA&>; + using UB1 = std::unique_ptr<B, DB&>; + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, const DA&>; + using UB1 = std::unique_ptr<B, const DB&>; + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A>; + using UA2 = std::unique_ptr<A[]>; + using UB1 = std::unique_ptr<B[]>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A, NCGenericDeleter>; + using UA2 = std::unique_ptr<A[], NCGenericDeleter>; + using UB1 = std::unique_ptr<B[], NCGenericDeleter>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } +} + +int main() { + test_sfinae(); + { + std::unique_ptr<B> bptr(new B); + std::unique_ptr<A> aptr(new A); + testAssign(aptr, bptr); + } + assert(A::count == 0); + assert(B::count == 0); + { + Deleter<B> del(42); + std::unique_ptr<B, Deleter<B> > bptr(new B, std::move(del)); + std::unique_ptr<A, Deleter<A> > aptr(new A); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 0); + } + assert(A::count == 0); + assert(B::count == 0); + { + CDeleter<A> adel(6); + CDeleter<B> bdel(42); + std::unique_ptr<B, CDeleter<B>&> bptr(new B, bdel); + std::unique_ptr<A, CDeleter<A>&> aptr(new A, adel); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 42); + } + assert(A::count == 0); + assert(B::count == 0); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp index e2d7956cda64..165d48a1caa5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp @@ -16,26 +16,24 @@ #include <memory> #include <cassert> -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; +#include "unique_ptr_test_helper.h" -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = 0; +// test assignment from null +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr<VT> s2(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + s2 = NULL; assert(A::count == 0); assert(s2.get() == 0); - } - assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp index fb1584951993..e1e2e32e23c4 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp @@ -16,26 +16,25 @@ #include <memory> #include <cassert> +#include "unique_ptr_test_helper.h" + // test assignment from null -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr<VT> s2(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); s2 = nullptr; assert(A::count == 0); assert(s2.get() == 0); - } - assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp new file mode 100644 index 000000000000..7d5e9bca63c4 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// libc++ cannot safely provide the auto_ptr constructor without rvalue +// references. +// REQUIRES: c++11 || c++14 + +// <memory> + +// unique_ptr + +// template <class U> unique_ptr(auto_ptr<U>&&) noexcept + +#include <memory> +#include <utility> +#include <cassert> + +#include "test_macros.h" + +struct A { + static int count; + A() { ++count; } + A(const A&) { ++count; } + virtual ~A() { --count; } +}; + +int A::count = 0; + +struct B : public A { + static int count; + B() { ++count; } + B(const B&) { ++count; } + virtual ~B() { --count; } +}; + +int B::count = 0; + +struct C {}; + +struct Deleter { + void operator()(void*) {} +}; + +void test_sfinae() { + { + // the auto_ptr constructor should be disable with a non-default deleter. + using AP = std::auto_ptr<int>; + using U = std::unique_ptr<int, Deleter>; + static_assert(!std::is_constructible<U, AP&&>::value, ""); + } + { + // the auto_ptr constructor should be disabled when the pointer types are incompatible. + using AP = std::auto_ptr<A>; + using U = std::unique_ptr<C>; + static_assert(!std::is_constructible<U, AP&&>::value, ""); + } +} + +int main() { + { + B* p = new B; + std::auto_ptr<B> ap(p); + std::unique_ptr<A> up(std::move(ap)); + assert(up.get() == p); + assert(ap.get() == 0); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + std::auto_ptr<B> ap(p); + std::unique_ptr<A> up; + up = std::move(ap); + assert(up.get() == p); + assert(ap.get() == 0); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); +#if TEST_STD_VER >= 11 + { + static_assert(std::is_nothrow_constructible<std::unique_ptr<A>, + std::auto_ptr<B>&&>::value, + ""); + } +#endif + test_sfinae(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp new file mode 100644 index 000000000000..51d9aa708c40 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp @@ -0,0 +1,107 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr() +// +// Concerns: +// 1 The default constructor works for any default constructible deleter types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Default construct unique_ptr's with various deleter types (C-1) +// 2 Default construct a unique_ptr with an incomplete element_type and +// various deleter types (C-1,2) + +#include <memory> +#include <cassert> +#include "test_macros.h" + +#include "test_macros.h" +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 +_LIBCPP_SAFE_STATIC std::unique_ptr<int> global_static_unique_ptr_single; +_LIBCPP_SAFE_STATIC std::unique_ptr<int[]> global_static_unique_ptr_runtime; +#endif + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; +#endif + +template <class ElemType> +void test_sfinae() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr<ElemType, void (*)(void*)>; + static_assert(!std::is_default_constructible<U>::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter<ElemType>; + using U1 = std::unique_ptr<ElemType, NonDefaultDeleter>; + using U2 = std::unique_ptr<ElemType, Del&>; + using U3 = std::unique_ptr<ElemType, Del const&>; + static_assert(!std::is_default_constructible<U1>::value, ""); + static_assert(!std::is_default_constructible<U2>::value, ""); + static_assert(!std::is_default_constructible<U3>::value, ""); + } +#endif +} + +template <class ElemType> +void test_basic() { +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr<ElemType>; + using U2 = std::unique_ptr<ElemType, Deleter<ElemType> >; + static_assert(std::is_nothrow_default_constructible<U1>::value, ""); + static_assert(std::is_nothrow_default_constructible<U2>::value, ""); + } +#endif + { + std::unique_ptr<ElemType> p; + assert(p.get() == 0); + } + { + std::unique_ptr<ElemType, NCDeleter<ElemType> > p; + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + p.get_deleter().set_state(5); + assert(p.get_deleter().state() == 5); + } +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + doIncompleteTypeTest(0); + doIncompleteTypeTest<IncompleteType, Deleter<IncompleteType> >(0); +} { + doIncompleteTypeTest<IncompleteType[]>(0); + doIncompleteTypeTest<IncompleteType[], Deleter<IncompleteType[]> >(0); +}) + +int main() { + { + test_sfinae<int>(); + test_basic<int>(); + } + { + test_sfinae<int[]>(); + test_basic<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp new file mode 100644 index 000000000000..c102f27fb8e6 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp @@ -0,0 +1,174 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// Test unique_ptr move ctor + +#include <memory> +#include <utility> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +//============================================================================= +// TESTING unique_ptr(unique_ptr&&) +// +// Concerns +// 1 The moved from pointer is empty and the new pointer stores the old value. +// 2 The only requirement on the deleter is that it is MoveConstructible +// or a reference. +// 3 The constructor works for explicitly moved values (ie std::move(x)) +// 4 The constructor works for true temporaries (ie a return value) +// +// Plan +// 1 Explicitly construct unique_ptr<T, D> for various deleter types 'D'. +// check that the value and deleter have been properly moved. (C-1,2,3) +// +// 2 Use the expression 'sink(source())' to move construct a unique_ptr<T, D> +// from a temporary. 'source' should return the unique_ptr by value and +// 'sink' should accept the unique_ptr by value. (C-1,2,4) + +template <class VT> +std::unique_ptr<VT> source1() { + return std::unique_ptr<VT>(newValue<VT>(1)); +} + +template <class VT> +std::unique_ptr<VT, Deleter<VT> > source2() { + return std::unique_ptr<VT, Deleter<VT> >(newValue<VT>(1), Deleter<VT>(5)); +} + +template <class VT> +std::unique_ptr<VT, NCDeleter<VT>&> source3() { + static NCDeleter<VT> d(5); + return std::unique_ptr<VT, NCDeleter<VT>&>(newValue<VT>(1), d); +} + +template <class VT> +void sink1(std::unique_ptr<VT> p) { + assert(p.get() != nullptr); +} + +template <class VT> +void sink2(std::unique_ptr<VT, Deleter<VT> > p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); +} + +template <class VT> +void sink3(std::unique_ptr<VT, NCDeleter<VT>&> p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); + assert(&p.get_deleter() == &source3<VT>().get_deleter()); +} + +template <class ValueT> +void test_sfinae() { + typedef std::unique_ptr<ValueT> U; + { // Ensure unique_ptr is non-copyable + static_assert((!std::is_constructible<U, U const&>::value), ""); + static_assert((!std::is_constructible<U, U&>::value), ""); + } +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<!IsArray, A, A[]>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + typedef std::unique_ptr<VT> APtr; + APtr s(newValue<VT>(expect_alive)); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + } + assert(A::count == 0); + { + typedef Deleter<VT> MoveDel; + typedef std::unique_ptr<VT, MoveDel> APtr; + MoveDel d(5); + APtr s(newValue<VT>(expect_alive), std::move(d)); + assert(d.state() == 0); + assert(s.get_deleter().state() == 5); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + assert(s2.get_deleter().state() == 5); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + { + typedef NCDeleter<VT> NonCopyDel; + typedef std::unique_ptr<VT, NonCopyDel&> APtr; + + NonCopyDel d; + APtr s(newValue<VT>(expect_alive), d); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + d.set_state(6); + assert(s2.get_deleter().state() == d.state()); + assert(s.get_deleter().state() == d.state()); + } + assert(A::count == 0); + { + sink1<VT>(source1<VT>()); + assert(A::count == 0); + sink2<VT>(source2<VT>()); + assert(A::count == 0); + sink3<VT>(source3<VT>()); + assert(A::count == 0); + } + assert(A::count == 0); +} + +template <class VT> +void test_noexcept() { +#if TEST_STD_VER >= 11 + { + typedef std::unique_ptr<VT> U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } + { + typedef std::unique_ptr<VT, Deleter<VT> > U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } + { + typedef std::unique_ptr<VT, NCDeleter<VT> &> U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } + { + typedef std::unique_ptr<VT, const NCConstDeleter<VT> &> U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } +#endif +} + +int main() { + { + test_basic</*IsArray*/ false>(); + test_sfinae<int>(); + test_noexcept<int>(); + } + { + test_basic</*IsArray*/ true>(); + test_sfinae<int[]>(); + test_noexcept<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.pass.cpp new file mode 100644 index 000000000000..6e5db86c97fc --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.pass.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <int ID = 0> +struct GenericDeleter { + void operator()(void*) const {} +}; + +template <int ID = 0> +struct GenericConvertingDeleter { + template <int OID> + GenericConvertingDeleter(GenericConvertingDeleter<OID>) {} + void operator()(void*) const {} +}; + +template <bool IsArray> +void test_sfinae() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<IsArray, A[], A>::type VT; + + { // Test that different non-reference deleter types are allowed so long + // as they convert to each other. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + } + { // Test that different non-reference deleter types are disallowed when + // they cannot convert. + using U1 = std::unique_ptr<VT, GenericDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericDeleter<1> >; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + } + { // Test that if the destination deleter is a reference type then only + // exact matches are allowed. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> const& >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U1, U3&&>::value, ""); + static_assert(!std::is_constructible<U1, U4&&>::value, ""); + static_assert(!std::is_constructible<U1, U5&&>::value, ""); + + using U1C = std::unique_ptr<const VT, GenericConvertingDeleter<0> const&>; + static_assert(std::is_nothrow_constructible<U1C, U1&&>::value, ""); + } + { // Test that non-reference destination deleters can be constructed + // from any source deleter type with a sutible conversion. Including + // reference types. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> const &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> &>; + using U6 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + static_assert(std::is_constructible<U1, U3&&>::value, ""); + static_assert(std::is_constructible<U1, U4&&>::value, ""); + static_assert(std::is_constructible<U1, U5&&>::value, ""); + static_assert(std::is_constructible<U1, U6&&>::value, ""); + } +#endif +} + + +template <bool IsArray> +void test_noexcept() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<IsArray, A[], A>::type VT; + { + typedef std::unique_ptr<const VT> APtr; + typedef std::unique_ptr<VT> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, CDeleter<const VT> > APtr; + typedef std::unique_ptr<VT, CDeleter<VT> > BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, NCDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, NCDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, const NCConstDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, const NCConstDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } +#endif +} + + +int main() { + { + test_sfinae</*IsArray*/false>(); + test_noexcept<false>(); + } + { + test_sfinae</*IsArray*/true>(); + test_noexcept<true>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp new file mode 100644 index 000000000000..09e842b5987f --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include <memory> +#include <cassert> + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +template <int ID = 0> +struct GenericDeleter { + void operator()(void*) const {} +}; + +template <int ID = 0> +struct GenericConvertingDeleter { + template <int OID> + GenericConvertingDeleter(GenericConvertingDeleter<OID>) {} + void operator()(void*) const {} +}; + +void test_sfinae() { + { // Disallow copying + using U1 = std::unique_ptr<A[], GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<A[], GenericConvertingDeleter<1> >; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U1, U2&>::value, ""); + static_assert(!std::is_constructible<U1, const U2&>::value, ""); + static_assert(!std::is_constructible<U1, const U2&&>::value, ""); + } + { // Disallow illegal qualified conversions + using U1 = std::unique_ptr<const A[]>; + using U2 = std::unique_ptr<A[]>; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U2, U1&&>::value, ""); + } + { // Disallow base-to-derived conversions. + using UA = std::unique_ptr<A[]>; + using UB = std::unique_ptr<B[]>; + static_assert(!std::is_constructible<UA, UB&&>::value, ""); + } + { // Disallow base-to-derived conversions. + using UA = std::unique_ptr<A[], GenericConvertingDeleter<0> >; + using UB = std::unique_ptr<B[], GenericConvertingDeleter<1> >; + static_assert(!std::is_constructible<UA, UB&&>::value, ""); + } + { // Disallow invalid deleter initialization + using U1 = std::unique_ptr<A[], GenericDeleter<0> >; + using U2 = std::unique_ptr<A[], GenericDeleter<1> >; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + } + { // Disallow reference deleters with different qualifiers + using U1 = std::unique_ptr<A[], Deleter<A[]>&>; + using U2 = std::unique_ptr<A[], const Deleter<A[]>&>; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U2, U1&&>::value, ""); + } + { + using U1 = std::unique_ptr<A[]>; + using U2 = std::unique_ptr<A>; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U2, U1&&>::value, ""); + } +} + + +int main() { + test_sfinae(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp new file mode 100644 index 000000000000..4e2a6dfa3dd1 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp @@ -0,0 +1,248 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// + +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +// NOTE: unique_ptr does not provide converting constructors in c++03 +// UNSUPPORTED: c++98, c++03 + +#include <memory> +#include <type_traits> +#include <utility> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +// test converting move ctor. Should only require a MoveConstructible deleter, or if +// deleter is a reference, not even that. +// Explicit version + +template <class LHS, class RHS> +void checkReferenceDeleter(LHS& lhs, RHS& rhs) { + typedef typename LHS::deleter_type NewDel; + static_assert(std::is_reference<NewDel>::value, ""); + rhs.get_deleter().set_state(42); + assert(rhs.get_deleter().state() == 42); + assert(lhs.get_deleter().state() == 42); + lhs.get_deleter().set_state(99); + assert(lhs.get_deleter().state() == 99); + assert(rhs.get_deleter().state() == 99); +} + +template <class LHS, class RHS> +void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { + assert(lhs.get_deleter().state() == LHSVal); + assert(rhs.get_deleter().state() == RHSVal); +} + +template <class LHS, class RHS> +void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { + assert(lhs.get() == RHSVal); + assert(rhs.get() == nullptr); + assert(A::count == 1); + assert(B::count == 1); +} + +void checkNoneAlive() { + assert(A::count == 0); + assert(B::count == 0); +} + +template <class T> +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +template <class T> +struct NCConvertingDeleter<T[]> { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter<A>; // non-copyable deleters + using DB = NCConvertingDeleter<B>; + using UA = std::unique_ptr<A>; + using UB = std::unique_ptr<B>; + using UAD = std::unique_ptr<A, DA>; + using UBD = std::unique_ptr<B, DB>; + { // cannot move from an lvalue + static_assert(std::is_constructible<UA, UB&&>::value, ""); + static_assert(!std::is_constructible<UA, UB&>::value, ""); + static_assert(!std::is_constructible<UA, const UB&>::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_constructible<UAD, UBD&&>::value, ""); + static_assert(!std::is_constructible<UAD, UB&&>::value, ""); + static_assert(!std::is_constructible<UA, UBD&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, DA&>; + using UB1 = std::unique_ptr<B, DB&>; + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, const DA&>; + using UB1 = std::unique_ptr<B, const DB&>; + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A>; + using UA2 = std::unique_ptr<A[]>; + using UB1 = std::unique_ptr<B[]>; + static_assert(!std::is_constructible<UA1, UA2&&>::value, ""); + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A, NCGenericDeleter>; + using UA2 = std::unique_ptr<A[], NCGenericDeleter>; + using UB1 = std::unique_ptr<B[], NCGenericDeleter>; + static_assert(!std::is_constructible<UA1, UA2&&>::value, ""); + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } +} + +void test_noexcept() { + { + typedef std::unique_ptr<A> APtr; + typedef std::unique_ptr<B> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<A, Deleter<A> > APtr; + typedef std::unique_ptr<B, Deleter<B> > BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<A, NCDeleter<A>&> APtr; + typedef std::unique_ptr<B, NCDeleter<A>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<A, const NCConstDeleter<A>&> APtr; + typedef std::unique_ptr<B, const NCConstDeleter<A>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } +} + +int main() { + { + test_sfinae(); + test_noexcept(); + } + { + typedef std::unique_ptr<A> APtr; + typedef std::unique_ptr<B> BPtr; + { // explicit + BPtr b(new B); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + } + checkNoneAlive(); + { // implicit + BPtr b(new B); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + } + checkNoneAlive(); + } + { // test with moveable deleters + typedef std::unique_ptr<A, Deleter<A> > APtr; + typedef std::unique_ptr<B, Deleter<B> > BPtr; + { + Deleter<B> del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + { + Deleter<B> del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + } + { // test with reference deleters + typedef std::unique_ptr<A, NCDeleter<A>&> APtr; + typedef std::unique_ptr<B, NCDeleter<A>&> BPtr; + NCDeleter<A> del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + } + { + typedef std::unique_ptr<A, CDeleter<A> > APtr; + typedef std::unique_ptr<B, CDeleter<B>&> BPtr; + CDeleter<B> del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp new file mode 100644 index 000000000000..8bc8a57c1c8d --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <memory> + +// unique_ptr + +// FIXME(EricWF): This test contains tests for constructing a unique_ptr from NULL. +// The behavior demonstrated in this test is not meant to be standard; It simply +// tests the current status quo in libc++. + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <class VT> +void test_pointer_ctor() { + { + std::unique_ptr<VT> p(0); + assert(p.get() == 0); + } + { + std::unique_ptr<VT, Deleter<VT> > p(0); + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + } +} + +template <class VT> +void test_pointer_deleter_ctor() { + { + std::default_delete<VT> d; + std::unique_ptr<VT> p(0, d); + assert(p.get() == 0); + } + { + std::unique_ptr<VT, Deleter<VT> > p(0, Deleter<VT>(5)); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } + { + NCDeleter<VT> d(5); + std::unique_ptr<VT, NCDeleter<VT>&> p(0, d); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } + { + NCConstDeleter<VT> d(5); + std::unique_ptr<VT, NCConstDeleter<VT> const&> p(0, d); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } +} + +int main() { + { + // test_pointer_ctor<int>(); + test_pointer_deleter_ctor<int>(); + } + { + test_pointer_ctor<int[]>(); + test_pointer_deleter_ctor<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp new file mode 100644 index 000000000000..6764935fee14 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp @@ -0,0 +1,106 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// unique_ptr(nullptr_t); + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + + +#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 +_LIBCPP_SAFE_STATIC std::unique_ptr<int> global_static_unique_ptr_single(nullptr); +_LIBCPP_SAFE_STATIC std::unique_ptr<int[]> global_static_unique_ptr_runtime(nullptr); +#endif + + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; +#endif + +template <class VT> +void test_basic() { +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr<VT>; + using U2 = std::unique_ptr<VT, Deleter<VT> >; + static_assert(std::is_nothrow_constructible<U1, decltype(nullptr)>::value, + ""); + static_assert(std::is_nothrow_constructible<U2, decltype(nullptr)>::value, + ""); + } +#endif + { + std::unique_ptr<VT> p(nullptr); + assert(p.get() == 0); + } + { + std::unique_ptr<VT, NCDeleter<VT> > p(nullptr); + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + } +} + +template <class VT> +void test_sfinae() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr<VT, void (*)(void*)>; + static_assert(!std::is_constructible<U, decltype(nullptr)>::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter<VT>; + using U1 = std::unique_ptr<VT, NonDefaultDeleter>; + using U2 = std::unique_ptr<VT, Del&>; + using U3 = std::unique_ptr<VT, Del const&>; + static_assert(!std::is_constructible<U1, decltype(nullptr)>::value, ""); + static_assert(!std::is_constructible<U2, decltype(nullptr)>::value, ""); + static_assert(!std::is_constructible<U3, decltype(nullptr)>::value, ""); + } +#endif +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + { doIncompleteTypeTest(0, nullptr); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest<IncompleteType, NCDeleter<IncompleteType> >(0, + nullptr); + } + checkNumIncompleteTypeAlive(0); + { doIncompleteTypeTest<IncompleteType[]>(0, nullptr); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest<IncompleteType[], NCDeleter<IncompleteType[]> >( + 0, nullptr); + } + checkNumIncompleteTypeAlive(0); +}) + +int main() { + { + test_basic<int>(); + test_sfinae<int>(); + } + { + test_basic<int[]>(); + test_sfinae<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp new file mode 100644 index 000000000000..8df259bd4e1d --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp @@ -0,0 +1,171 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr(pointer) +// +// Concerns: +// 1 The pointer constructor works for any default constructible deleter types. +// 2 The pointer constructor accepts pointers to derived types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Construct unique_ptr<T, D>'s with a pointer to 'T' and various deleter +// types (C-1) +// 2 Construct unique_ptr<T, D>'s with a pointer to 'D' and various deleter +// types where 'D' is derived from 'T'. (C-1,2) +// 3 Construct a unique_ptr<T, D> with a pointer to 'T' and various deleter +// types where 'T' is an incomplete type (C-1,3) + +// Test unique_ptr(pointer) ctor + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +// unique_ptr(pointer) ctor should only require default Deleter ctor + +template <bool IsArray> +void test_pointer() { + typedef typename std::conditional<!IsArray, A, A[]>::type ValueT; + const int expect_alive = IsArray ? 5 : 1; +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr<ValueT>; + using U2 = std::unique_ptr<ValueT, Deleter<ValueT> >; + + // Test for noexcept + static_assert(std::is_nothrow_constructible<U1, A*>::value, ""); + static_assert(std::is_nothrow_constructible<U2, A*>::value, ""); + + // Test for explicit + static_assert(!std::is_convertible<A*, U1>::value, ""); + static_assert(!std::is_convertible<A*, U2>::value, ""); + } +#endif + { + A* p = newValue<ValueT>(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr<ValueT> s(p); + assert(s.get() == p); + } + assert(A::count == 0); + { + A* p = newValue<ValueT>(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr<ValueT, NCDeleter<ValueT> > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); +} + +void test_derived() { + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr<A> s(p); + assert(s.get() == p); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr<A, NCDeleter<A> > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + assert(B::count == 0); +} + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; + +struct GenericDeleter { + void operator()(void*) const; +}; +#endif + +template <class T> +void test_sfinae() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr<T, void (*)(void*)>; + static_assert(!std::is_constructible<U, T*>::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter<T>; + using U1 = std::unique_ptr<T, NonDefaultDeleter>; + using U2 = std::unique_ptr<T, Del&>; + using U3 = std::unique_ptr<T, Del const&>; + static_assert(!std::is_constructible<U1, T*>::value, ""); + static_assert(!std::is_constructible<U2, T*>::value, ""); + static_assert(!std::is_constructible<U3, T*>::value, ""); + } +#endif +} + +static void test_sfinae_runtime() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resolution when + // a base <-> derived conversion would occur. + using UA = std::unique_ptr<A[]>; + using UAD = std::unique_ptr<A[], GenericDeleter>; + using UAC = std::unique_ptr<const A[]>; + using UB = std::unique_ptr<B[]>; + using UBD = std::unique_ptr<B[], GenericDeleter>; + using UBC = std::unique_ptr<const B[]>; + + static_assert(!std::is_constructible<UA, B*>::value, ""); + static_assert(!std::is_constructible<UB, A*>::value, ""); + static_assert(!std::is_constructible<UAD, B*>::value, ""); + static_assert(!std::is_constructible<UBD, A*>::value, ""); + static_assert(!std::is_constructible<UAC, const B*>::value, ""); + static_assert(!std::is_constructible<UBC, const A*>::value, ""); + } +#endif +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + { doIncompleteTypeTest(1, getNewIncomplete()); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest<IncompleteType, NCDeleter<IncompleteType> >( + 1, getNewIncomplete()); + } + checkNumIncompleteTypeAlive(0); +}) + +int main() { + { + test_pointer</*IsArray*/ false>(); + test_derived(); + test_sfinae<int>(); + } + { + test_pointer</*IsArray*/ true>(); + test_sfinae<int[]>(); + test_sfinae_runtime(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp index ad64b5e4ea39..b4cd3f36ab57 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp @@ -20,11 +20,10 @@ #include <memory> struct Deleter { - void operator()(int* p) const {delete p;} + void operator()(int* p) const { delete p; } }; -int main() -{ - // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} - std::unique_ptr<int, const Deleter&> s((int*)nullptr, Deleter()); // expected-note {{requested here}} +int main() { + // expected-error@+1 {{call to deleted constructor of 'std::unique_ptr<int, const Deleter &>}} + std::unique_ptr<int, const Deleter&> s((int*)nullptr, Deleter()); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp new file mode 100644 index 000000000000..781794d41b5e --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp @@ -0,0 +1,328 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +//============================================================================= +// TESTING unique_ptr(pointer, deleter) +// +// Concerns: +// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. +// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. +// 3 unique_ptr<T, D&>(pointer, deleter) does not require a CopyConstructible deleter. +// 4 unique_ptr<T, D const&>(pointer, deleter) does not require a CopyConstructible deleter. +// 5 unique_ptr(pointer, deleter) should work for derived pointers. +// 6 unique_ptr(pointer, deleter) should work with function pointers. +// 7 unique_ptr<void> should work. + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +bool my_free_called = false; + +void my_free(void*) { my_free_called = true; } + +#if TEST_STD_VER >= 11 +struct DeleterBase { + void operator()(void*) const {} +}; +struct CopyOnlyDeleter : DeleterBase { + CopyOnlyDeleter() = default; + CopyOnlyDeleter(CopyOnlyDeleter const&) = default; + CopyOnlyDeleter(CopyOnlyDeleter&&) = delete; +}; +struct MoveOnlyDeleter : DeleterBase { + MoveOnlyDeleter() = default; + MoveOnlyDeleter(MoveOnlyDeleter&&) = default; +}; +struct NoCopyMoveDeleter : DeleterBase { + NoCopyMoveDeleter() = default; + NoCopyMoveDeleter(NoCopyMoveDeleter const&) = delete; +}; +#endif + +template <bool IsArray> +void test_sfinae() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<!IsArray, int, int[]>::type VT; + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(std::is_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_constructible<U, int*, D&>::value, ""); + static_assert(std::is_constructible<U, int*, D&&>::value, ""); + // FIXME: __libcpp_compressed_pair attempts to perform a move even though + // it should only copy. + //D d; + //U u(nullptr, std::move(d)); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(!std::is_constructible<U, int*, D const&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&>::value, ""); + static_assert(std::is_constructible<U, int*, D&&>::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(!std::is_constructible<U, int*, D const&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, D&>; + static_assert(!std::is_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_constructible<U, int*, D&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&&>::value, ""); + static_assert(!std::is_constructible<U, int*, const D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, const D&>; + static_assert(std::is_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_constructible<U, int*, D&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&&>::value, ""); + static_assert(!std::is_constructible<U, int*, const D&&>::value, ""); + } +#endif +} + +template <bool IsArray> +void test_noexcept() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<!IsArray, int, int[]>::type VT; + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(std::is_nothrow_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, int*, D&>::value, ""); + static_assert(std::is_nothrow_constructible<U, int*, D&&>::value, ""); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(std::is_nothrow_constructible<U, int*, D&&>::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, D&>; + static_assert(std::is_nothrow_constructible<U, int*, D&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, const D&>; + static_assert(std::is_nothrow_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, int*, D&>::value, ""); + } +#endif +} + +void test_sfinae_runtime() { +#if TEST_STD_VER >= 11 + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr<A[], D>; + static_assert(std::is_nothrow_constructible<U, A*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + // FIXME: __libcpp_compressed_pair attempts to perform a move even though + // it should only copy. + //D d; + //U u(nullptr, std::move(d)); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr<A[], D>; + static_assert(!std::is_constructible<U, A*, D const&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<A[], D>; + static_assert(!std::is_constructible<U, A*, D const&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<A[], D&>; + static_assert(!std::is_constructible<U, A*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&&>::value, ""); + static_assert(!std::is_constructible<U, A*, const D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + static_assert(!std::is_constructible<U, B*, const D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<A[], const D&>; + static_assert(std::is_nothrow_constructible<U, A*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&&>::value, ""); + static_assert(!std::is_constructible<U, A*, const D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + static_assert(!std::is_constructible<U, B*, const D&&>::value, ""); + } +#endif +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<!IsArray, A, A[]>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { // MoveConstructible deleter (C-1) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr<VT, Deleter<VT> > s(p, Deleter<VT>(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // CopyConstructible deleter (C-2) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + CopyDeleter<VT> d(5); + std::unique_ptr<VT, CopyDeleter<VT> > s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // Reference deleter (C-3) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + NCDeleter<VT> d(5); + std::unique_ptr<VT, NCDeleter<VT>&> s(p, d); + assert(s.get() == p); + assert(&s.get_deleter() == &d); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 6); + } + assert(A::count == 0); + { // Const Reference deleter (C-4) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + NCConstDeleter<VT> d(5); + std::unique_ptr<VT, NCConstDeleter<VT> const&> s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + assert(&s.get_deleter() == &d); + } + assert(A::count == 0); + { // Void and function pointers (C-6,7) + typedef typename std::conditional<IsArray, int[], int>::type VT2; + my_free_called = false; + { + int i = 0; + std::unique_ptr<VT2, void (*)(void*)> s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} + +void test_basic_single() { + assert(A::count == 0); + assert(B::count == 0); + { // Derived pointers (C-5) + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + assert(B::count == 0); + { // Void and function pointers (C-6,7) + my_free_called = false; + { + int i = 0; + std::unique_ptr<void, void (*)(void*)> s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} + +template <bool IsArray> +void test_nullptr() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<!IsArray, A, A[]>::type VT; + { + std::unique_ptr<VT, Deleter<VT> > u(nullptr, Deleter<VT>{}); + assert(u.get() == nullptr); + } + { + NCDeleter<VT> d; + std::unique_ptr<VT, NCDeleter<VT>& > u(nullptr, d); + assert(u.get() == nullptr); + } + { + NCConstDeleter<VT> d; + std::unique_ptr<VT, NCConstDeleter<VT> const& > u(nullptr, d); + assert(u.get() == nullptr); + } +#endif +} + +int main() { + { + test_basic</*IsArray*/ false>(); + test_nullptr<false>(); + test_basic_single(); + test_sfinae<false>(); + test_noexcept<false>(); + } + { + test_basic</*IsArray*/ true>(); + test_nullptr<true>(); + test_sfinae<true>(); + test_sfinae_runtime(); + test_noexcept<true>(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp index 064f38c5f167..fa10ade51206 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp @@ -16,29 +16,33 @@ #include <memory> #include <cassert> -class Deleter -{ - int state_; +class Deleter { + int state_; - Deleter(Deleter&); - Deleter& operator=(Deleter&); + Deleter(Deleter&); + Deleter& operator=(Deleter&); public: - Deleter() : state_(0) {} + Deleter() : state_(0) {} - int state() const {return state_;} + int state() const { return state_; } - void operator()(void*) {++state_;} + void operator()(void*) { ++state_; } }; -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr<int, Deleter&> p(0, d); - assert(p.get() == 0); +template <class T> +void test_basic() { + Deleter d; + assert(d.state() == 0); + { + std::unique_ptr<T, Deleter&> p(nullptr, d); + assert(p.get() == nullptr); assert(&p.get_deleter() == &d); - } - assert(d.state() == 0); + } + assert(d.state() == 0); +} + +int main() { + test_basic<int>(); + test_basic<int[]>(); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp new file mode 100644 index 000000000000..f7f20945094e --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test release + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.release()); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* ap = p.get(); + A* a = p.release(); + assert(A::count == expect_alive); + assert(p.get() == nullptr); + assert(ap == a); + assert(a != nullptr); + + if (IsArray) + delete[] a; + else + delete a; + + assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp new file mode 100644 index 000000000000..c95c55b4adf8 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp @@ -0,0 +1,117 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test reset + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <bool IsArray> +void test_reset_pointer() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.reset((A*)nullptr)); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + A* new_value = newValue<VT>(expect_alive); + assert(A::count == (expect_alive * 2)); + p.reset(new_value); + assert(A::count == expect_alive); + assert(p.get() == new_value); + } + assert(A::count == 0); + { + std::unique_ptr<const VT> p(newValue<const VT>(expect_alive)); + assert(A::count == expect_alive); + const A* i = p.get(); + assert(i != nullptr); + A* new_value = newValue<VT>(expect_alive); + assert(A::count == (expect_alive * 2)); + p.reset(new_value); + assert(A::count == expect_alive); + assert(p.get() == new_value); + } + assert(A::count == 0); +} + +template <bool IsArray> +void test_reset_nullptr() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.reset(nullptr)); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + p.reset(nullptr); + assert(A::count == 0); + assert(p.get() == nullptr); + } + assert(A::count == 0); +} + + +template <bool IsArray> +void test_reset_no_arg() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.reset()); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + p.reset(); + assert(A::count == 0); + assert(p.get() == nullptr); + } + assert(A::count == 0); +} + +int main() { + { + test_reset_pointer</*IsArray*/ false>(); + test_reset_nullptr<false>(); + test_reset_no_arg<false>(); + } + { + test_reset_pointer</*IsArray*/true>(); + test_reset_nullptr<true>(); + test_reset_no_arg<true>(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp index 9ec9b9527e8a..0d067b9abff5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp @@ -11,29 +11,20 @@ // unique_ptr -// test op*() +// test reset #include <memory> #include <cassert> -int main() -{ - { - std::unique_ptr<int[]> p(new int [3]); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { +#include "unique_ptr_test_helper.h" + +int main() { + { + std::unique_ptr<A[]> p; + p.reset(static_cast<B*>(nullptr)); // expected-error {{no matching member function for call to 'reset'}} + } + { std::unique_ptr<int[]> p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } + p.reset(static_cast<const int*>(nullptr)); // expected-error {{no matching member function for call to 'reset'}} + } } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp index 2de7787b267e..8f2a69913dde 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp @@ -16,30 +16,10 @@ #include <memory> #include <cassert> -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; +#include "unique_ptr_test_helper.h" -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { +int main() { + { std::unique_ptr<A> p(new A); assert(A::count == 1); assert(B::count == 0); @@ -48,10 +28,10 @@ int main() p.reset(new B); assert(A::count == 1); assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { + } + assert(A::count == 0); + assert(B::count == 0); + { std::unique_ptr<A> p(new B); assert(A::count == 1); assert(B::count == 1); @@ -60,7 +40,7 @@ int main() p.reset(new B); assert(A::count == 1); assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); + } + assert(A::count == 0); + assert(B::count == 0); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp index 58b05efa25f6..f838661c53f0 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp @@ -15,15 +15,11 @@ #include <memory> -struct A -{ - std::unique_ptr<A> ptr_; +struct A { + std::unique_ptr<A> ptr_; - A() : ptr_(this) {} - void reset() {ptr_.reset();} + A() : ptr_(this) {} + void reset() { ptr_.reset(); } }; -int main() -{ - (new A)->reset(); -} +int main() { (new A)->reset(); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp new file mode 100644 index 000000000000..de18865c50ae --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test swap + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +struct TT { + int state_; + static int count; + TT() : state_(-1) { ++count; } + explicit TT(int i) : state_(i) { ++count; } + TT(const TT& a) : state_(a.state_) { ++count; } + TT& operator=(const TT& a) { + state_ = a.state_; + return *this; + } + ~TT() { --count; } + + friend bool operator==(const TT& x, const TT& y) { + return x.state_ == y.state_; + } +}; + +int TT::count = 0; + +template <class T> +typename std::remove_all_extents<T>::type* newValueInit(int size, + int new_value) { + typedef typename std::remove_all_extents<T>::type VT; + VT* p = newValue<T>(size); + for (int i = 0; i < size; ++i) + (p + i)->state_ = new_value; + return p; +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, TT[], TT>::type VT; + const int expect_alive = IsArray ? 5 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT, Deleter<VT> >; + U u; ((void)u); + ASSERT_NOEXCEPT(u.swap(u)); + } +#endif + { + TT* p1 = newValueInit<VT>(expect_alive, 1); + std::unique_ptr<VT, Deleter<VT> > s1(p1, Deleter<VT>(1)); + TT* p2 = newValueInit<VT>(expect_alive, 2); + std::unique_ptr<VT, Deleter<VT> > s2(p2, Deleter<VT>(2)); + assert(s1.get() == p1); + assert(*s1.get() == TT(1)); + assert(s1.get_deleter().state() == 1); + assert(s2.get() == p2); + assert(*s2.get() == TT(2)); + assert(s2.get_deleter().state() == 2); + s1.swap(s2); + assert(s1.get() == p2); + assert(*s1.get() == TT(2)); + assert(s1.get_deleter().state() == 2); + assert(s2.get() == p1); + assert(*s2.get() == TT(1)); + assert(s2.get_deleter().state() == 1); + assert(TT::count == (expect_alive * 2)); + } + assert(TT::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp index d5c7445b0d86..b05fb71cdc67 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp @@ -16,24 +16,9 @@ #include <memory> #include <cassert> -int main() -{ - { - std::unique_ptr<int> p(new int(3)); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { - std::unique_ptr<int> p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } +int main() { + std::unique_ptr<int[]> p(new int(3)); + const std::unique_ptr<int[]>& cp = p; + (void)(*p); // expected-error {{indirection requires pointer operand ('std::unique_ptr<int []>' invalid)}} + (void)(*cp); // expected-error {{indirection requires pointer operand ('const std::unique_ptr<int []>' invalid)}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp index 9d0cfcaaf353..b2d3da48daee 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp @@ -16,8 +16,7 @@ #include <memory> #include <cassert> -int main() -{ - std::unique_ptr<int> p(new int(3)); - assert(*p == 3); +int main() { + std::unique_ptr<int> p(new int(3)); + assert(*p == 3); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp new file mode 100644 index 000000000000..9a6d6c65fa81 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test op*() + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <class UPtr> +void doTest(UPtr& p, bool ExpectTrue) { + if (p) + assert(ExpectTrue); + else + assert(!ExpectTrue); + + if (!p) + assert(!ExpectTrue); + else + assert(ExpectTrue); +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + typedef std::unique_ptr<VT> U; + { + static_assert((std::is_constructible<bool, U>::value), ""); + static_assert((std::is_constructible<bool, U const&>::value), ""); + } +#if TEST_STD_VER >= 11 + { + static_assert(!std::is_convertible<U, bool>::value, ""); + static_assert(!std::is_convertible<U const&, bool>::value, ""); + } +#endif + { + U p(newValue<VT>(1)); + U const& cp = p; + doTest(p, true); + doTest(cp, true); + } + { + U p; + const U& cp = p; + doTest(p, false); + doTest(cp, false); + } +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp new file mode 100644 index 000000000000..518e31cf9487 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test get + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + typedef const VT CVT; + { + typedef std::unique_ptr<VT> U; + int* p = newValue<VT>(1); + U s(p); + U const& sc = s; + ASSERT_SAME_TYPE(decltype(s.get()), int*); + ASSERT_SAME_TYPE(decltype(sc.get()), int*); + assert(s.get() == p); + assert(sc.get() == s.get()); + } + { + typedef std::unique_ptr<CVT> U; + const int* p = newValue<VT>(1); + U s(p); + U const& sc = s; + ASSERT_SAME_TYPE(decltype(s.get()), const int*); + ASSERT_SAME_TYPE(decltype(sc.get()), const int*); + assert(s.get() == p); + assert(sc.get() == s.get()); + } +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp new file mode 100644 index 000000000000..6a00d14a2cae --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test get_deleter() + +#include <memory> +#include <cassert> +#include "test_macros.h" + +struct Deleter { + Deleter() {} + + void operator()(void*) const {} + + int test() { return 5; } + int test() const { return 6; } +}; + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + { + std::unique_ptr<int, Deleter> p; + assert(p.get_deleter().test() == 5); + } + { + const std::unique_ptr<VT, Deleter> p; + assert(p.get_deleter().test() == 6); + } + { + typedef std::unique_ptr<VT, const Deleter&> UPtr; + const Deleter d; + UPtr p(nullptr, d); + const UPtr& cp = p; + ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&); + ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&); + assert(p.get_deleter().test() == 6); + assert(cp.get_deleter().test() == 6); + } + { + typedef std::unique_ptr<VT, Deleter&> UPtr; + Deleter d; + UPtr p(nullptr, d); + const UPtr& cp = p; + ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&); + ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&); + assert(p.get_deleter().test() == 5); + assert(cp.get_deleter().test() == 5); + } +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp new file mode 100644 index 000000000000..d66af054ce64 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test op->() + +#include <memory> +#include <cassert> + +struct V { + int member; +}; + +int main() { + std::unique_ptr<V[]> p; + std::unique_ptr<V[]> const& cp = p; + + p->member; // expected-error {{member reference type 'std::unique_ptr<V []>' is not a pointer}} + // expected-error@-1 {{no member named 'member'}} + + cp->member; // expected-error {{member reference type 'const std::unique_ptr<V []>' is not a pointer}} + // expected-error@-1 {{no member named 'member'}} +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp index 47de8f66ed2e..8bed9dda2ead 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp @@ -16,15 +16,13 @@ #include <memory> #include <cassert> -struct A -{ - int i_; +struct A { + int i_; - A() : i_(7) {} + A() : i_(7) {} }; -int main() -{ - std::unique_ptr<A> p(new A); - assert(p->i_ == 7); +int main() { + std::unique_ptr<A> p(new A); + assert(p->i_ == 7); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp index 21e829cbc444..b47c35afb4f5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp @@ -16,32 +16,33 @@ #include <memory> #include <cassert> -class A -{ - int state_; - static int next_; +class A { + int state_; + static int next_; + public: - A() : state_(++next_) {} - int get() const {return state_;} + A() : state_(++next_) {} + int get() const { return state_; } - friend bool operator==(const A& x, int y) - {return x.state_ == y;} + friend bool operator==(const A& x, int y) { return x.state_ == y; } - A& operator=(int i) {state_ = i; return *this;} + A& operator=(int i) { + state_ = i; + return *this; + } }; int A::next_ = 0; -int main() -{ - std::unique_ptr<A> p(new A[3]); - assert(p[0] == 1); - assert(p[1] == 2); - assert(p[2] == 3); - p[0] = 3; - p[1] = 2; - p[2] = 1; - assert(p[0] == 3); - assert(p[1] == 2); - assert(p[2] == 1); +int main() { + std::unique_ptr<A[]> p(new A[3]); + assert(p[0] == 1); + assert(p[1] == 2); + assert(p[2] == 3); + p[0] = 3; + p[1] = 2; + p[2] = 1; + assert(p[0] == 3); + assert(p[1] == 2); + assert(p[2] == 1); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp index 2ae0659adc26..529749da67e9 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp @@ -11,14 +11,14 @@ // unique_ptr -// test get +// test op[](size_t) #include <memory> #include <cassert> -int main() -{ - int* p = new int[3]; - std::unique_ptr<int[]> s(p); - assert(s.get() == p); +int main() { + std::unique_ptr<int> p(new int[3]); + std::unique_ptr<int> const& cp = p; + p[0]; // expected-error {{type 'std::unique_ptr<int>' does not provide a subscript operator}} + cp[1]; // expected-error {{type 'const std::unique_ptr<int>' does not provide a subscript operator}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp index 30b4ecb94e18..30b4ecb94e18 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp index 00987919413b..00987919413b 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp index cc94e9ab3aaa..cc94e9ab3aaa 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp index cfdc2e1d886b..cfdc2e1d886b 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp index 07aa659bd9b0..07aa659bd9b0 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp index ace2e4fc7137..ace2e4fc7137 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp index b58f5c55b643..b58f5c55b643 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp index 9bf794caeda2..9bf794caeda2 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp index f686e9f01f11..f686e9f01f11 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp index 255e5cd39c69..255e5cd39c69 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp index 5d1cf1ff4981..5d1cf1ff4981 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp index 41209d977b71..41209d977b71 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp index 2949d6310c59..2949d6310c59 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp index 7a409766412f..7a409766412f 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp index 528b10e9085d..528b10e9085d 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp index b58f5c55b643..b58f5c55b643 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp index 22ae217a61d6..22ae217a61d6 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp index 37886548e721..88a1e04ba4ec 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp @@ -22,7 +22,7 @@ #include <memory> #include <cassert> -#include "../deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp index 80653cf707c3..94ae89ba92b3 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp @@ -30,7 +30,7 @@ #include <memory> #include <cassert> -#include "../deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp index c525137d4841..7ac0ba490e97 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp @@ -17,7 +17,7 @@ #include <cassert> #include "test_macros.h" -#include "../deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp b/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp index bc65078911b2..8eab082cf676 100644 --- a/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp @@ -30,6 +30,8 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); + H h; T bs(static_cast<unsigned long long>(N)); const std::size_t result = h(bs); diff --git a/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp b/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp new file mode 100644 index 000000000000..1d8bff41ae53 --- /dev/null +++ b/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <bitset> + +// Test that <bitset> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <bitset> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::bitset<0> >(); + test_hash_enabled_for_type<std::bitset<1> >(); + test_hash_enabled_for_type<std::bitset<1024> >(); + test_hash_enabled_for_type<std::bitset<100000> >(); + } +} diff --git a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp index 5387b733918f..de1cddb5b1ae 100644 --- a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp @@ -10,6 +10,7 @@ // test bool all() const; #include <bitset> +#include <type_traits> #include <cassert> template <std::size_t N> @@ -20,7 +21,8 @@ void test_all() assert(v.all() == (N == 0)); v.set(); assert(v.all() == true); - if (N > 1) + const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings + if (greater_than_1) { v[N/2] = false; assert(v.all() == false); diff --git a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp index aa6384a49df1..7ee83dd07482 100644 --- a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp @@ -10,6 +10,7 @@ // test bool any() const; #include <bitset> +#include <type_traits> #include <cassert> template <std::size_t N> @@ -20,7 +21,8 @@ void test_any() assert(v.any() == false); v.set(); assert(v.any() == (N != 0)); - if (N > 1) + const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings + if (greater_than_1) { v[N/2] = false; assert(v.any() == true); diff --git a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp index 02e58a7890c5..f352475fc199 100644 --- a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp @@ -10,6 +10,7 @@ // test bitset<N>::reference operator[](size_t pos); #include <bitset> +#include <type_traits> #include <cstdlib> #include <cassert> @@ -31,7 +32,8 @@ template <std::size_t N> void test_index_const() { std::bitset<N> v1 = make_bitset<N>(); - if (N > 0) + const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings + if (greater_than_0) { assert(v1[N/2] == v1.test(N/2)); typename std::bitset<N>::reference r = v1[N/2]; diff --git a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp index 870a504c2d75..fbde54859f19 100644 --- a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp @@ -10,6 +10,7 @@ // test constexpr bool operator[](size_t pos) const; #include <bitset> +#include <type_traits> #include <cstdlib> #include <cassert> @@ -31,7 +32,8 @@ template <std::size_t N> void test_index_const() { const std::bitset<N> v1 = make_bitset<N>(); - if (N > 0) + const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings + if (greater_than_0) { assert(v1[N/2] == v1.test(N/2)); } diff --git a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp index b65c636f3c56..1358eaa62d59 100644 --- a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp @@ -10,6 +10,7 @@ // test bool none() const; #include <bitset> +#include <type_traits> #include <cassert> template <std::size_t N> @@ -20,7 +21,8 @@ void test_none() assert(v.none() == true); v.set(); assert(v.none() == (N == 0)); - if (N > 1) + const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings + if (greater_than_1) { v[N/2] = false; assert(v.none() == false); diff --git a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp index 24761c628c03..5b7e10d677ee 100644 --- a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp @@ -13,6 +13,7 @@ // bool operator!=(const bitset<N>& rhs) const; #include <bitset> +#include <type_traits> #include <cstdlib> #include <cassert> @@ -36,7 +37,8 @@ void test_equality() const std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; assert(v1 == v2); - if (N > 0) + const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings + if (greater_than_0) { v2[N/2].flip(); assert(v1 != v2); diff --git a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp index 27d8480d10cf..a2c9df6b4a22 100644 --- a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp @@ -11,6 +11,7 @@ #include <bitset> #include <algorithm> +#include <type_traits> #include <climits> #include <cassert> @@ -18,8 +19,9 @@ template <std::size_t N> void test_to_ullong() { const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N; - const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; - const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X; + const bool is_M_zero = std::integral_constant<bool, M == 0>::value; // avoid compiler warnings + const std::size_t X = is_M_zero ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; + const unsigned long long max = is_M_zero ? 0 : (unsigned long long)(-1) >> X; unsigned long long tests[] = {0, std::min<unsigned long long>(1, max), std::min<unsigned long long>(2, max), diff --git a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp index 3ad1abade9f4..7cabd06e5f32 100644 --- a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp @@ -11,6 +11,7 @@ #include <bitset> #include <algorithm> +#include <type_traits> #include <limits> #include <climits> #include <cassert> @@ -19,8 +20,9 @@ template <std::size_t N> void test_to_ulong() { const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N; - const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; - const std::size_t max = M == 0 ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X; + const bool is_M_zero = std::integral_constant<bool, M == 0>::value; // avoid compiler warnings + const std::size_t X = is_M_zero ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; + const std::size_t max = is_M_zero ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X; std::size_t tests[] = {0, std::min<std::size_t>(1, max), std::min<std::size_t>(2, max), diff --git a/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp index b6b3aeea94f8..bf2a2e589137 100644 --- a/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp +++ b/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // Due to C++17 inline variables ASAN flags this test as containing an ODR // violation because Clock::is_steady is defined in both the dylib and this TU. diff --git a/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp index 6302ce6efb34..b836c0dc00e6 100644 --- a/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp +++ b/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // UNSUPPORTED: libcpp-has-no-monotonic-clock // Due to C++17 inline variables ASAN flags this test as containing an ODR diff --git a/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp index cfbe9bd57032..a4058e5ab97b 100644 --- a/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp +++ b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // Due to C++17 inline variables ASAN flags this test as containing an ODR // violation because Clock::is_steady is defined in both the dylib and this TU. diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp index c0f10147ee89..b85f039526a4 100644 --- a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp +++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp @@ -11,11 +11,13 @@ // duration -// duration operator+() const; +// constexpr common_type_t<duration> operator+() const; #include <chrono> #include <cassert> +#include <test_macros.h> + int main() { { @@ -23,11 +25,22 @@ int main() std::chrono::minutes m2 = +m; assert(m.count() == m2.count()); } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { constexpr std::chrono::minutes m(3); constexpr std::chrono::minutes m2 = +m; static_assert(m.count() == m2.count(), ""); } #endif + +// P0548 + { + typedef std::chrono::duration<int, std::ratio<10,10> > D10; + typedef std::chrono::duration<int, std::ratio< 1, 1> > D1; + D10 zero(0); + D10 one(1); + static_assert( (std::is_same< decltype(+one), decltype(zero-one) >::value), ""); + static_assert( (std::is_same< decltype(zero+one), D1>::value), ""); + static_assert( (std::is_same< decltype(+one), D1>::value), ""); + } } diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp index 00da6f69ca53..347cc1980e81 100644 --- a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp +++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp @@ -11,11 +11,13 @@ // duration -// duration operator-() const; +// constexpr common_type_t<duration> operator-() const; #include <chrono> #include <cassert> +#include <test_macros.h> + int main() { { @@ -23,11 +25,23 @@ int main() std::chrono::minutes m2 = -m; assert(m2.count() == -m.count()); } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { constexpr std::chrono::minutes m(3); constexpr std::chrono::minutes m2 = -m; static_assert(m2.count() == -m.count(), ""); } #endif + +// P0548 + { + typedef std::chrono::duration<int, std::ratio<10,10> > D10; + typedef std::chrono::duration<int, std::ratio< 1, 1> > D1; + D10 zero(0); + D10 one(1); + static_assert( (std::is_same< decltype(-one), decltype(zero-one) >::value), ""); + static_assert( (std::is_same< decltype(zero-one), D1>::value), ""); + static_assert( (std::is_same< decltype(-one), D1>::value), ""); + static_assert( (std::is_same< decltype(+one), D1>::value), ""); + } } diff --git a/test/std/utilities/tuple/tuple.general/ignore.pass.cpp b/test/std/utilities/tuple/tuple.general/ignore.pass.cpp new file mode 100644 index 000000000000..8dae3a5dcb0e --- /dev/null +++ b/test/std/utilities/tuple/tuple.general/ignore.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <tuple> + +// constexpr unspecified ignore; + +// UNSUPPORTED: c++98, c++03 + +#include <tuple> +#include <cassert> + +#include "test_macros.h" + +constexpr bool test_ignore_constexpr() +{ +#if TEST_STD_VER > 11 + { // Test that std::ignore provides constexpr converting assignment. + auto& res = (std::ignore = 42); + assert(&res == &std::ignore); + } + { // Test that std::ignore provides constexpr copy/move constructors + auto copy = std::ignore; + auto moved = std::move(copy); + ((void)moved); + } + { // Test that std::ignore provides constexpr copy/move assignment + auto copy = std::ignore; + copy = std::ignore; + auto moved = std::ignore; + moved = std::move(copy); + } +#endif + return true; +} + +int main() { + { + constexpr auto& ignore_v = std::ignore; + ((void)ignore_v); + } + { + static_assert(test_ignore_constexpr(), ""); + } +#if defined(_LIBCPP_VERSION) + { + static_assert(std::is_trivial<decltype(std::ignore)>::value, ""); + } +#endif +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp index eee1dd88253c..bd91ce61b4ec 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp @@ -66,7 +66,7 @@ constexpr bool do_constexpr_test(Tuple&& tup) { return std::make_from_tuple<Tp>(std::forward<Tuple>(tup)).args == tup; } -// Needed by do_forwarding_test() since it compare pairs of different types. +// Needed by do_forwarding_test() since it compares pairs of different types. template <class T1, class T2, class U1, class U2> inline bool operator==(const std::pair<T1, T2>& lhs, const std::pair<U1, U2>& rhs) { return lhs.first == rhs.first && lhs.second == rhs.second; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp index 4ddfb463385c..0d3b7ff24edb 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp @@ -89,7 +89,7 @@ int main() // when both #1 and #2 participate in partial ordering #2 will always // be chosen over #1. // See PR22806 and LWG issue #2549 for more information. - // (https://llvm.org/bugs/show_bug.cgi?id=22806) + // (https://bugs.llvm.org/show_bug.cgi?id=22806) using T = std::tuple<int>; std::allocator<int> A; { // rvalue reference @@ -144,8 +144,8 @@ int main() assert(&std::get<0>(t2) == &t1); } // Test constructing a 1-tuple of the form tuple<UDT> from another 1-tuple - // 'tuple<T>' where UDT *can* be constructed from 'tuple<T>' In this case - // the 'tuple(UTypes...)' ctor should be choosen and 'UDT' constructed frow + // 'tuple<T>' where UDT *can* be constructed from 'tuple<T>'. In this case + // the 'tuple(UTypes...)' ctor should be chosen and 'UDT' constructed from // 'tuple<T>'. { using VT = ConstructibleFromTupleAndInt; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp index 4da5fc7f8397..b262f3cacecf 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp @@ -18,7 +18,7 @@ // NOTE: this constructor does not currently support tags derived from // allocator_arg_t because libc++ has to deduce the parameter as a template -// argument. See PR27684 (https://llvm.org/bugs/show_bug.cgi?id=27684) +// argument. See PR27684 (https://bugs.llvm.org/show_bug.cgi?id=27684) #include <tuple> #include <cassert> @@ -96,7 +96,7 @@ int main() } { // Test that the uses-allocator default constructor does not evaluate - // it's SFINAE when it otherwise shouldn't be selected. Do this by + // its SFINAE when it otherwise shouldn't be selected. Do this by // using 'NonDefaultConstructible' which will cause a compile error // if std::is_default_constructible is evaluated on it. using T = NonDefaultConstructible<>; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp index d282c9c68a42..eeaa8a24ee68 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp @@ -100,8 +100,8 @@ int main() assert(std::get<1>(t) == nullptr); } { - // Check that the SFINAE on the default constructor is not evaluted when - // it isn't needed. If the default constructor is evaluted then this test + // Check that the SFINAE on the default constructor is not evaluated when + // it isn't needed. If the default constructor is evaluated then this test // should fail to compile. IllFormedDefault v(0); std::tuple<IllFormedDefault> t(v); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp index c4c3c242d8f8..5dc98afe6610 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp @@ -22,6 +22,24 @@ #include "test_macros.h" +#if TEST_STD_VER > 11 +constexpr bool test_tie_constexpr() { + { + int i = 42; + double f = 1.1; + using ExpectT = std::tuple<int&, decltype(std::ignore)&, double&>; + auto res = std::tie(i, std::ignore, f); + static_assert(std::is_same<ExpectT, decltype(res)>::value, ""); + assert(&std::get<0>(res) == &i); + assert(&std::get<1>(res) == &std::ignore); + assert(&std::get<2>(res) == &f); + // FIXME: If/when tuple gets constexpr assignment + //res = std::make_tuple(101, nullptr, -1.0); + } + return true; +} +#endif + int main() { { @@ -39,5 +57,8 @@ int main() static_assert ( std::get<0>(t) == 42, "" ); static_assert ( std::get<1>(t) == 1.1, "" ); } + { + static_assert(test_tie_constexpr(), ""); + } #endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/test/std/utilities/type.index/type.index.hash/enabled_hash.pass.cpp index 82b84948f3f0..26bada38fdd5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp +++ b/test/std/utilities/type.index/type.index.hash/enabled_hash.pass.cpp @@ -7,24 +7,17 @@ // //===----------------------------------------------------------------------===// -// <memory> +// UNSUPPORTED: c++98, c++03 -// unique_ptr +// <typeindex> -// Test unique_ptr default ctor +// Test that <typeindex> provides all of the arithmetic, enum, and pointer +// hash specializations. -// default unique_ptr ctor should require non-reference Deleter ctor +#include <typeindex> -#include <memory> +#include "poisoned_hash_helper.hpp" -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter&> p; +int main() { + test_library_hash_specializations_available(); } diff --git a/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp b/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp index 6d353f1d3057..9ab58ea6c3aa 100644 --- a/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp +++ b/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp @@ -18,9 +18,21 @@ #include <typeindex> #include <type_traits> +#include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "poisoned_hash_helper.hpp" +#endif + int main() { + { typedef std::hash<std::type_index> H; static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + } +#if TEST_STD_VER >= 11 + { + test_hash_enabled_for_type<std::type_index>(std::type_index(typeid(int))); + } +#endif } diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp index 2623b800fff7..cf1afff90cda 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// REQUIRES-ANY: c++98, c++03 +// REQUIRES: c++98 || c++03 // <utility> diff --git a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp index 8f9fc669251a..d5e1e232f86f 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp @@ -32,7 +32,7 @@ struct DeletedDefault { // A class with a deleted default constructor. Used to test the SFINAE - // on std::pairs default constructor. + // on std::pair's default constructor. constexpr explicit DeletedDefault(int x) : value(x) {} constexpr DeletedDefault() = delete; int value; diff --git a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp index ace00a16f21e..af91abe74e1e 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp @@ -15,7 +15,7 @@ // This test doesn't pass due to a constexpr bug in GCC 4.9 that fails // to initialize any type without a user provided constructor in a constant -// expression (ie float). +// expression (e.g. float). // XFAIL: gcc-4.9 // NOTE: The SFINAE on the default constructor is tested in @@ -49,7 +49,7 @@ int main() using P = std::pair<int, NoDefault>; static_assert(!std::is_default_constructible<P>::value, ""); using P2 = std::pair<NoDefault, int>; - static_assert(!std::is_default_constructible<P>::value, ""); + static_assert(!std::is_default_constructible<P2>::value, ""); } #endif } diff --git a/test/std/utilities/variant/variant.get/get_index.pass.cpp b/test/std/utilities/variant/variant.get/get_index.pass.cpp index 72d17b0ed971..bc7a566040eb 100644 --- a/test/std/utilities/variant/variant.get/get_index.pass.cpp +++ b/test/std/utilities/variant/variant.get/get_index.pass.cpp @@ -36,7 +36,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<0>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); @@ -52,7 +52,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42l); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<1>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); diff --git a/test/std/utilities/variant/variant.get/get_type.pass.cpp b/test/std/utilities/variant/variant.get/get_type.pass.cpp index fc355378a21a..013a081f5c77 100644 --- a/test/std/utilities/variant/variant.get/get_type.pass.cpp +++ b/test/std/utilities/variant/variant.get/get_type.pass.cpp @@ -30,7 +30,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<int>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); @@ -46,7 +46,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42l); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<const long>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &); diff --git a/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp b/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp new file mode 100644 index 000000000000..826dcbae6b9f --- /dev/null +++ b/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <variant> + +// Test that <variant> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <variant> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); +} diff --git a/test/std/utilities/variant/variant.hash/hash.pass.cpp b/test/std/utilities/variant/variant.hash/hash.pass.cpp index d807a7c7e2ea..2ad2184f4db1 100644 --- a/test/std/utilities/variant/variant.hash/hash.pass.cpp +++ b/test/std/utilities/variant/variant.hash/hash.pass.cpp @@ -21,6 +21,7 @@ #include "test_macros.h" #include "variant_test_helpers.hpp" +#include "poisoned_hash_helper.hpp" #ifndef TEST_HAS_NO_EXCEPTIONS namespace std { @@ -101,8 +102,12 @@ void test_hash_monostate() { assert(h(m1) == h(m2)); { ASSERT_SAME_TYPE(decltype(h(m1)), std::size_t); + ASSERT_NOEXCEPT(h(m1)); static_assert(std::is_copy_constructible<H>::value, ""); } + { + test_hash_enabled_for_type<std::monostate>(); + } } void test_hash_variant_duplicate_elements() { @@ -117,8 +122,38 @@ void test_hash_variant_duplicate_elements() { LIBCPP_ASSERT(h(v1) != h(v2)); } +struct A {}; +struct B {}; + +namespace std { + +template <> +struct hash<B> { + size_t operator()(B const&) const { + return 0; + } +}; + +} + +void test_hash_variant_enabled() { + { + test_hash_enabled_for_type<std::variant<int> >(); + test_hash_enabled_for_type<std::variant<int*, long, double, const int> >(); + } + { + test_hash_disabled_for_type<std::variant<int, A>>(); + test_hash_disabled_for_type<std::variant<const A, void*>>(); + } + { + test_hash_enabled_for_type<std::variant<int, B>>(); + test_hash_enabled_for_type<std::variant<const B, int>>(); + } +} + int main() { test_hash_variant(); test_hash_variant_duplicate_elements(); test_hash_monostate(); + test_hash_variant_enabled(); } diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp index 8f694cfd5eda..0d0b978e3959 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp @@ -14,7 +14,8 @@ // template <class ...Types> class variant; -// template <size_t I, class ...Args> void emplace(Args&&... args); +// template <size_t I, class ...Args> +// variant_alternative_t<I, variant<Types...>>& emplace(Args&&... args); #include <cassert> #include <string> @@ -85,10 +86,14 @@ void test_basic() { { using V = std::variant<int>; V v(42); - v.emplace<0>(); + auto& ref1 = v.emplace<0>(); + static_assert(std::is_same_v<int&, decltype(ref1)>, ""); assert(std::get<0>(v) == 0); - v.emplace<0>(42); + assert(&ref1 == &std::get<0>(v)); + auto& ref2 = v.emplace<0>(42); + static_assert(std::is_same_v<int&, decltype(ref2)>, ""); assert(std::get<0>(v) == 42); + assert(&ref2 == &std::get<0>(v)); } { using V = @@ -96,13 +101,19 @@ void test_basic() { const int x = 100; V v(std::in_place_index<0>, -1); // default emplace a value - v.emplace<1>(); + auto& ref1 = v.emplace<1>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<1>(v) == 0); - v.emplace<2>(&x); + assert(&ref1 == &std::get<1>(v)); + auto& ref2 = v.emplace<2>(&x); + static_assert(std::is_same_v<const void*&, decltype(ref2)>, ""); assert(std::get<2>(v) == &x); + assert(&ref2 == &std::get<2>(v)); // emplace with multiple args - v.emplace<4>(3, 'a'); + auto& ref3 = v.emplace<4>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref3)>, ""); assert(std::get<4>(v) == "aaa"); + assert(&ref3 == &std::get<4>(v)); } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { @@ -113,20 +124,30 @@ void test_basic() { int z = 43; V v(std::in_place_index<0>, -1); // default emplace a value - v.emplace<1>(); + auto& ref1 = v.emplace<1>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<1>(v) == 0); + assert(&ref1 == &std::get<1>(v)); // emplace a reference - v.emplace<2>(x); + auto& ref2 = v.emplace<2>(x); + static_assert(std::is_same_v<&, decltype(ref)>, ""); assert(&std::get<2>(v) == &x); + assert(&ref2 == &std::get<2>(v)); // emplace an rvalue reference - v.emplace<3>(std::move(y)); + auto& ref3 = v.emplace<3>(std::move(y)); + static_assert(std::is_same_v<&, decltype(ref)>, ""); assert(&std::get<3>(v) == &y); + assert(&ref3 == &std::get<3>(v)); // re-emplace a new reference over the active member - v.emplace<3>(std::move(z)); + auto& ref4 = v.emplace<3>(std::move(z)); + static_assert(std::is_same_v<&, decltype(ref)>, ""); assert(&std::get<3>(v) == &z); + assert(&ref4 == &std::get<3>(v)); // emplace with multiple args - v.emplace<5>(3, 'a'); + auto& ref5 = v.emplace<5>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref5)>, ""); assert(std::get<5>(v) == "aaa"); + assert(&ref5 == &std::get<5>(v)); } #endif } diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp index f466b160cb4f..e69988a08e96 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp @@ -15,7 +15,7 @@ // template <class ...Types> class variant; // template <size_t I, class U, class ...Args> -// void emplace(initializer_list<U> il,Args&&... args); +// variant_alternative_t<I, variant<Types...>>& emplace(initializer_list<U> il,Args&&... args); #include <cassert> #include <string> @@ -70,13 +70,19 @@ void test_emplace_sfinae() { void test_basic() { using V = std::variant<int, InitList, InitListArg, TestTypes::NoCtors>; V v; - v.emplace<1>({1, 2, 3}); + auto& ref1 = v.emplace<1>({1, 2, 3}); + static_assert(std::is_same_v<InitList&, decltype(ref1)>, ""); assert(std::get<1>(v).size == 3); - v.emplace<2>({1, 2, 3, 4}, 42); + assert(&ref1 == &std::get<1>(v)); + auto& ref2 = v.emplace<2>({1, 2, 3, 4}, 42); + static_assert(std::is_same_v<InitListArg&, decltype(ref2)>, ""); assert(std::get<2>(v).size == 4); assert(std::get<2>(v).value == 42); - v.emplace<1>({1}); + assert(&ref2 == &std::get<2>(v)); + auto& ref3 = v.emplace<1>({1}); + static_assert(std::is_same_v<InitList&, decltype(ref3)>, ""); assert(std::get<1>(v).size == 1); + assert(&ref3 == &std::get<1>(v)); } int main() { diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp index 4ca2cc4803e3..8e329024b9df 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp @@ -14,7 +14,7 @@ // template <class ...Types> class variant; -// template <class T, class ...Args> void emplace(Args&&... args); +// template <class T, class ...Args> T& emplace(Args&&... args); #include <cassert> #include <string> @@ -86,10 +86,14 @@ void test_basic() { { using V = std::variant<int>; V v(42); - v.emplace<int>(); + auto& ref1 = v.emplace<int>(); + static_assert(std::is_same_v<int&, decltype(ref1)>, ""); assert(std::get<0>(v) == 0); - v.emplace<int>(42); + assert(&ref1 == &std::get<0>(v)); + auto& ref2 = v.emplace<int>(42); + static_assert(std::is_same_v<int&, decltype(ref2)>, ""); assert(std::get<0>(v) == 42); + assert(&ref2 == &std::get<0>(v)); } { using V = @@ -97,13 +101,19 @@ void test_basic() { const int x = 100; V v(std::in_place_type<int>, -1); // default emplace a value - v.emplace<long>(); + auto& ref1 = v.emplace<long>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<1>(v) == 0); - v.emplace<const void *>(&x); + assert(&ref1 == &std::get<1>(v)); + auto& ref2 = v.emplace<const void *>(&x); + static_assert(std::is_same_v<const void *&, decltype(ref2)>, ""); assert(std::get<2>(v) == &x); + assert(&ref2 == &std::get<2>(v)); // emplace with multiple args - v.emplace<std::string>(3, 'a'); + auto& ref3 = v.emplace<std::string>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref3)>, ""); assert(std::get<4>(v) == "aaa"); + assert(&ref3 == &std::get<4>(v)); } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { @@ -114,20 +124,30 @@ void test_basic() { int z = 43; V v(std::in_place_index<0>, -1); // default emplace a value - v.emplace<long>(); + auto& ref1 = v.emplace<long>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<long>(v) == 0); + assert(&ref1 == &std::get<long>(v)); // emplace a reference - v.emplace<const int &>(x); + auto& ref2 = v.emplace<const int &>(x); + static_assert(std::is_same_v<const int&, decltype(ref2)>, ""); assert(&std::get<const int &>(v) == &x); + assert(&ref2 == &std::get<const int &>(v)); // emplace an rvalue reference - v.emplace<int &&>(std::move(y)); + auto& ref3 = v.emplace<int &&>(std::move(y)); + static_assert(std::is_same_v<int &&, decltype(ref3)>, ""); assert(&std::get<int &&>(v) == &y); + assert(&ref3 == &std::get<int &&>(v)); // re-emplace a new reference over the active member - v.emplace<int &&>(std::move(z)); + auto& ref4 = v.emplace<int &&>(std::move(z)); + static_assert(std::is_same_v<int &, decltype(ref4)>, ""); assert(&std::get<int &&>(v) == &z); + assert(&ref4 == &std::get<int &&>(v)); // emplace with multiple args - v.emplace<std::string>(3, 'a'); + auto& ref5 = v.emplace<std::string>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref5)>, ""); assert(std::get<std::string>(v) == "aaa"); + assert(&ref5 == &std::get<std::string>(v)); } #endif } diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp index b2be8ac5b3fd..da1658cb88f6 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp @@ -15,7 +15,7 @@ // template <class ...Types> class variant; // template <class T, class U, class ...Args> -// void emplace(initializer_list<U> il,Args&&... args); +// T& emplace(initializer_list<U> il,Args&&... args); #include <cassert> #include <string> @@ -70,13 +70,19 @@ void test_emplace_sfinae() { void test_basic() { using V = std::variant<int, InitList, InitListArg, TestTypes::NoCtors>; V v; - v.emplace<InitList>({1, 2, 3}); + auto& ref1 = v.emplace<InitList>({1, 2, 3}); + static_assert(std::is_same_v<InitList&,decltype(ref1)>, ""); assert(std::get<InitList>(v).size == 3); - v.emplace<InitListArg>({1, 2, 3, 4}, 42); + assert(&ref1 == &std::get<InitList>(v)); + auto& ref2 = v.emplace<InitListArg>({1, 2, 3, 4}, 42); + static_assert(std::is_same_v<InitListArg&,decltype(ref2)>, ""); assert(std::get<InitListArg>(v).size == 4); assert(std::get<InitListArg>(v).value == 42); - v.emplace<InitList>({1}); + assert(&ref2 == &std::get<InitListArg>(v)); + auto& ref3 = v.emplace<InitList>({1}); + static_assert(std::is_same_v<InitList&,decltype(ref3)>, ""); assert(std::get<InitList>(v).size == 1); + assert(&ref3 == &std::get<InitList>(v)); } int main() { diff --git a/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp b/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp index 6675b5f2b2ba..8025b9e0774e 100644 --- a/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp @@ -10,10 +10,13 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 -// The following compilers don't allow constexpr variables of non-literal type. +// The following compilers don't consider a type an aggregate type (and +// consequently not a literal type) if it has a base class at all. +// In C++17, an aggregate type is allowed to have a base class if it's not +// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors). // XFAIL: gcc-5, gcc-6 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 // <variant> diff --git a/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp b/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp index a0c57e132403..660a21c4f31d 100644 --- a/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp @@ -10,10 +10,13 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 -// The following compilers don't allow constexpr variables of non-literal type. +// The following compilers don't consider a type an aggregate type (and +// consequently not a literal type) if it has a base class at all. +// In C++17, an aggregate type is allowed to have a base class if it's not +// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors). // XFAIL: gcc-5, gcc-6 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 // <variant> |