Index: libcxx/include/algorithm =================================================================== --- libcxx/include/algorithm +++ libcxx/include/algorithm @@ -2305,7 +2305,7 @@ // rotate template -_ForwardIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __rotate_left(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type value_type; @@ -2316,7 +2316,7 @@ } template -_BidirectionalIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) { typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; @@ -2328,7 +2328,7 @@ } template -_ForwardIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { _ForwardIterator __i = __middle; @@ -2364,7 +2364,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -_Integral +_LIBCPP_CONSTEXPR_AFTER_CXX17 _Integral __algo_gcd(_Integral __x, _Integral __y) { do @@ -2377,7 +2377,7 @@ } template -_RandomAccessIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; @@ -2413,7 +2413,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -_ForwardIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _VSTD::forward_iterator_tag) { @@ -2428,7 +2428,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -_BidirectionalIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _VSTD::bidirectional_iterator_tag) { @@ -2445,7 +2445,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -_RandomAccessIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _VSTD::random_access_iterator_tag) { @@ -2463,7 +2463,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -_ForwardIterator +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { if (__first == __middle) Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp =================================================================== --- libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp +++ libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp @@ -419,6 +419,25 @@ #endif // TEST_STD_VER >= 11 +#if TEST_STD_VER > 17 + +template +constexpr bool test_constexr() +{ + int ia[] = {0, 1, 1, 3, 4}; + const int expected[] = {1, 3, 4, 0, 1}; + const size_t n = 2; + const Iter b = Iter(std::begin(ia)); + const Iter m = Iter(std::begin(ia) + n); + const Iter e = Iter(std::end(ia)); + + std::rotate(b, m, e); + return std::equal(std::begin(expected), std::end(expected), std::begin(ia)); +} + +#endif // TEST_STD_VER > 17 + + int main(int, char**) { test >(); @@ -435,5 +454,12 @@ #endif +#if TEST_STD_VER > 17 + static_assert(test_constexr >()); + static_assert(test_constexr >()); + static_assert(test_constexr >()); + static_assert(test_constexr()); +#endif // TEST_STD_VER > 17 + return 0; }