diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -267,7 +267,7 @@ unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred); template - void + constexpr void // constexpr in C++20 reverse(BidirectionalIterator first, BidirectionalIterator last); template @@ -306,7 +306,7 @@ is_partitioned(InputIterator first, InputIterator last, Predicate pred); template - ForwardIterator + constexpr ForwardIterator // constexpr in C++20 partition(ForwardIterator first, ForwardIterator last, Predicate pred); template - bool + constexpr bool // constexpr in C++20 next_permutation(BidirectionalIterator first, BidirectionalIterator last); template - bool + constexpr bool // constexpr in C++20 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); template - bool + constexpr bool // constexpr in C++20 prev_permutation(BidirectionalIterator first, BidirectionalIterator last); template - bool + constexpr bool // constexpr in C++20 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); } // std @@ -2311,7 +2311,7 @@ // reverse template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag) { @@ -2325,7 +2325,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) { @@ -2335,7 +2335,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) { @@ -3270,7 +3270,7 @@ // partition template -_ForwardIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) { while (true) @@ -3293,7 +3293,7 @@ } template -_BidirectionalIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) { @@ -3318,7 +3318,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { @@ -5636,7 +5636,7 @@ // next_permutation template -bool +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { _BidirectionalIterator __i = __last; @@ -5663,7 +5663,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { @@ -5672,7 +5672,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) { @@ -5683,7 +5683,7 @@ // prev_permutation template -bool +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { _BidirectionalIterator __i = __last; @@ -5710,7 +5710,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { @@ -5719,7 +5719,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) { diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp @@ -11,7 +11,7 @@ // template Pred> // requires ShuffleIterator // && CopyConstructible -// Iter +// constexpr Iter // constexpr in C++20 // partition(Iter first, Iter last, Pred pred); #include @@ -23,11 +23,11 @@ struct is_odd { - bool operator()(const int& i) const {return i & 1;} + TEST_CONSTEXPR bool operator()(const int& i) const {return i & 1;} }; template -void +TEST_CONSTEXPR_CXX20 bool test() { // check mixed @@ -92,6 +92,8 @@ assert(is_odd()(*i)); for (int* i = base(r); i < ia+sa; ++i) assert(!is_odd()(*i)); + + return true; } int main(int, char**) @@ -100,5 +102,11 @@ test >(); test(); - return 0; +#if TEST_STD_VER >= 20 + static_assert(test>()); + static_assert(test>()); + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp @@ -10,7 +10,7 @@ // template // requires HasSwap -// void +// constexpr void // constexpr in C++20 // reverse(Iter first, Iter last); #include @@ -20,7 +20,7 @@ #include "test_iterators.h" template -void +TEST_CONSTEXPR_CXX20 bool test() { int ia[] = {0}; @@ -50,6 +50,8 @@ assert(id[1] == 2); assert(id[2] == 1); assert(id[3] == 0); + + return true; } int main(int, char**) @@ -58,5 +60,11 @@ test >(); test(); - return 0; +#if TEST_STD_VER >= 20 + static_assert(test>()); + static_assert(test>()); + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp --- a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp @@ -11,7 +11,7 @@ // template // requires ShuffleIterator // && LessThanComparable -// bool +// constexpr bool // constexpr in C++20 // next_permutation(Iter first, Iter last); #include @@ -22,7 +22,7 @@ #include -int factorial(int x) +TEST_CONSTEXPR_CXX14 int factorial(int x) { int r = 1; for (; x; --x) @@ -31,7 +31,7 @@ } template -void +TEST_CONSTEXPR_CXX20 bool test() { int ia[] = {1, 2, 3, 4, 5, 6}; @@ -56,6 +56,7 @@ } while (x); assert(count == factorial(e)); } + return true; } int main(int, char**) @@ -64,5 +65,11 @@ test >(); test(); - return 0; +#if TEST_STD_VER >= 20 + static_assert(test>()); + static_assert(test>()); + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp --- a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp @@ -11,7 +11,7 @@ // template Compare> // requires ShuffleIterator // && CopyConstructible -// bool +// constexpr bool // constexpr in C++20 // next_permutation(Iter first, Iter last, Compare comp); #include @@ -23,7 +23,7 @@ #include -int factorial(int x) +TEST_CONSTEXPR_CXX14 int factorial(int x) { int r = 1; for (; x; --x) @@ -32,7 +32,7 @@ } template -void +TEST_CONSTEXPR_CXX20 bool test() { typedef std::greater C; @@ -58,6 +58,7 @@ } while (x); assert(count == factorial(e)); } + return true; } int main(int, char**) @@ -66,5 +67,11 @@ test >(); test(); - return 0; +#if TEST_STD_VER >= 20 + static_assert(test>()); + static_assert(test>()); + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp --- a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp @@ -11,7 +11,7 @@ // template // requires ShuffleIterator // && LessThanComparable -// bool +// constexpr bool // constexpr in C++20 // prev_permutation(Iter first, Iter last); #include @@ -22,7 +22,7 @@ #include -int factorial(int x) +TEST_CONSTEXPR_CXX14 int factorial(int x) { int r = 1; for (; x; --x) @@ -31,7 +31,7 @@ } template -void +TEST_CONSTEXPR_CXX20 bool test() { int ia[] = {6, 5, 4, 3, 2, 1}; @@ -56,6 +56,7 @@ } while (x); assert(count == factorial(e)); } + return true; } int main(int, char**) @@ -64,5 +65,11 @@ test >(); test(); - return 0; +#if TEST_STD_VER >= 20 + static_assert(test>()); + static_assert(test>()); + static_assert(test()); +#endif + + return 0; } diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp --- a/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp @@ -11,7 +11,7 @@ // template Compare> // requires ShuffleIterator // && CopyConstructible -// bool +// constexpr bool // constexpr in C++20 // prev_permutation(Iter first, Iter last, Compare comp); #include @@ -23,7 +23,7 @@ #include -int factorial(int x) +TEST_CONSTEXPR_CXX14 int factorial(int x) { int r = 1; for (; x; --x) @@ -32,7 +32,7 @@ } template -void +TEST_CONSTEXPR_CXX20 bool test() { typedef std::greater C; @@ -58,6 +58,7 @@ } while (x); assert(count == factorial(e)); } + return true; } int main(int, char**) @@ -66,5 +67,11 @@ test >(); test(); - return 0; +#if TEST_STD_VER >= 20 + static_assert(test>()); + static_assert(test>()); + static_assert(test()); +#endif + + return 0; }