+2019-08-14 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ Implement C++20 p0879 - Constexpr for swap and swap related functions.
+ * include/std/version (__cpp_lib_constexpr_swap_algorithms): New macro.
+ * include/bits/algorithmfwd.h (__cpp_lib_constexpr_swap_algorithms):
+ New macro.
+ (iter_swap, make_heap, next_permutation, partial_sort_copy, pop_heap)
+ (prev_permutation, push_heap, reverse, rotate, sort_heap, swap)
+ (swap_ranges, nth_element, partial_sort, sort): Add constexpr.
+ * include/bits/move.h (swap): Add constexpr.
+ * include/bits/stl_algo.h (__move_median_to_first, __reverse, reverse)
+ (__gcd, __rotate, rotate, __partition, __heap_select)
+ (__partial_sort_copy, partial_sort_copy, __unguarded_partition)
+ (__unguarded_partition_pivot, __partial_sort, __introsort_loop, __sort)
+ (__introselect, __chunk_insertion_sort, next_permutation)
+ (prev_permutation, partition, partial_sort, nth_element, sort)
+ (__iter_swap::iter_swap, iter_swap, swap_ranges): Add constexpr.
+ * include/bits/stl_algobase.h (__iter_swap::iter_swap, iter_swap)
+ (swap_ranges): Add constexpr.
+ * include/bits/stl_heap.h (__push_heap, push_heap, __adjust_heap,
+ __pop_heap, pop_heap, __make_heap, make_heap, __sort_heap, sort_heap):
+ Add constexpr.
+ * include/std/type_traits (swap): Add constexpr.
+ * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Add constexpr.
+ * testsuite/25_algorithms/iter_swap/constexpr.cc: New test.
+ * testsuite/25_algorithms/make_heap/constexpr.cc: New test.
+ * testsuite/25_algorithms/next_permutation/constexpr.cc: New test.
+ * testsuite/25_algorithms/nth_element/constexpr.cc: New test.
+ * testsuite/25_algorithms/partial_sort/constexpr.cc: New test.
+ * testsuite/25_algorithms/partial_sort_copy/constexpr.cc: New test.
+ * testsuite/25_algorithms/partition/constexpr.cc: New test.
+ * testsuite/25_algorithms/pop_heap/constexpr.cc: New test.
+ * testsuite/25_algorithms/prev_permutation/constexpr.cc: New test.
+ * testsuite/25_algorithms/push_heap/constexpr.cc: New test.
+ * testsuite/25_algorithms/reverse/constexpr.cc: New test.
+ * testsuite/25_algorithms/rotate/constexpr.cc: New test.
+ * testsuite/25_algorithms/sort/constexpr.cc: New test.
+ * testsuite/25_algorithms/sort_heap/constexpr.cc: New test.
+ * testsuite/25_algorithms/swap/constexpr.cc: New test.
+ * testsuite/25_algorithms/swap_ranges/constexpr.cc: New test.
+
2019-08-12 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/90361
#if __cplusplus > 201703L
# define __cpp_lib_constexpr_algorithms 201711L
+# define __cpp_lib_constexpr_swap_algorithms 201806L
#endif
#if __cplusplus >= 201103L
#endif
template<typename _FIter1, typename _FIter2>
+ _GLIBCXX20_CONSTEXPR
void
iter_swap(_FIter1, _FIter2);
lower_bound(_FIter, _FIter, const _Tp&, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
make_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
make_heap(_RAIter, _RAIter, _Compare);
// mismatch
template<typename _BIter>
+ _GLIBCXX20_CONSTEXPR
bool
next_permutation(_BIter, _BIter);
template<typename _BIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
bool
next_permutation(_BIter, _BIter, _Compare);
// partial_sort
template<typename _IIter, typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
_RAIter
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter);
template<typename _IIter, typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
_RAIter
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare);
#endif
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
pop_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
pop_heap(_RAIter, _RAIter, _Compare);
template<typename _BIter>
+ _GLIBCXX20_CONSTEXPR
bool
prev_permutation(_BIter, _BIter);
template<typename _BIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
bool
prev_permutation(_BIter, _BIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
push_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
push_heap(_RAIter, _RAIter, _Compare);
// replace_if
template<typename _BIter>
+ _GLIBCXX20_CONSTEXPR
void
reverse(_BIter, _BIter);
inline namespace _V2
{
template<typename _FIter>
+ _GLIBCXX20_CONSTEXPR
_FIter
rotate(_FIter, _FIter, _FIter);
}
#endif
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
sort_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
sort_heap(_RAIter, _RAIter, _Compare);
// For C++11 swap() is declared in <type_traits>.
template<typename _Tp, size_t _Nm>
+ _GLIBCXX20_CONSTEXPR
inline void
swap(_Tp& __a, _Tp& __b);
template<typename _Tp, size_t _Nm>
+ _GLIBCXX20_CONSTEXPR
inline void
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]);
#endif
template<typename _FIter1, typename _FIter2>
+ _GLIBCXX20_CONSTEXPR
_FIter2
swap_ranges(_FIter1, _FIter1, _FIter2);
mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
nth_element(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
nth_element(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
partial_sort(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _BIter, typename _Predicate>
+ _GLIBCXX20_CONSTEXPR
_BIter
partition(_BIter, _BIter, _Predicate);
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
sort(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
sort(_RAIter, _RAIter, _Compare);
* @return Nothing.
*/
template<typename _Tp>
+ _GLIBCXX20_CONSTEXPR
inline
#if __cplusplus >= 201103L
typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
// DR 809. std::swap should be overloaded for array types.
/// Swap the contents of two arrays.
template<typename _Tp, size_t _Nm>
+ _GLIBCXX20_CONSTEXPR
inline
#if __cplusplus >= 201103L
typename enable_if<__is_swappable<_Tp>::value>::type
/// Swaps the median value of *__a, *__b and *__c under __comp to *__result
template<typename _Iterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b,
_Iterator __c, _Compare __comp)
* overloaded for bidirectional iterators.
*/
template<typename _BidirectionalIterator>
+ _GLIBCXX20_CONSTEXPR
void
__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last,
bidirectional_iterator_tag)
* overloaded for random access iterators.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
void
__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag)
* swaps @p *(__first+i) and @p *(__last-(i+1))
*/
template<typename _BidirectionalIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
* It returns the greatest common divisor of two integer values.
*/
template<typename _EuclideanRingElement>
+ _GLIBCXX20_CONSTEXPR
_EuclideanRingElement
__gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
{
/// This is a helper function for the rotate algorithm.
template<typename _ForwardIterator>
+ _GLIBCXX20_CONSTEXPR
_ForwardIterator
__rotate(_ForwardIterator __first,
_ForwardIterator __middle,
/// This is a helper function for the rotate algorithm.
template<typename _BidirectionalIterator>
+ _GLIBCXX20_CONSTEXPR
_BidirectionalIterator
__rotate(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
/// This is a helper function for the rotate algorithm.
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
_RandomAccessIterator
__rotate(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
* for each @p n in the range @p [0,__last-__first).
*/
template<typename _ForwardIterator>
+ _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle,
_ForwardIterator __last)
/// This is a helper function...
template<typename _ForwardIterator, typename _Predicate>
+ _GLIBCXX20_CONSTEXPR
_ForwardIterator
__partition(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred, forward_iterator_tag)
/// This is a helper function...
template<typename _BidirectionalIterator, typename _Predicate>
+ _GLIBCXX20_CONSTEXPR
_BidirectionalIterator
__partition(_BidirectionalIterator __first, _BidirectionalIterator __last,
_Predicate __pred, bidirectional_iterator_tag)
/// This is a helper function for the sort routines.
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__heap_select(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
template<typename _InputIterator, typename _RandomAccessIterator,
typename _Compare>
+ _GLIBCXX20_CONSTEXPR
_RandomAccessIterator
__partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first,
* The value returned is @p __result_first+N.
*/
template<typename _InputIterator, typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first,
*/
template<typename _InputIterator, typename _RandomAccessIterator,
typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first,
/// This is a helper function...
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
_RandomAccessIterator
__unguarded_partition(_RandomAccessIterator __first,
_RandomAccessIterator __last,
/// This is a helper function...
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline _RandomAccessIterator
__unguarded_partition_pivot(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
}
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
__partial_sort(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Size, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__introsort_loop(_RandomAccessIterator __first,
_RandomAccessIterator __last,
// sort
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
__sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
}
template<typename _RandomAccessIterator, typename _Size, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
_RandomAccessIterator __last, _Size __depth_limit,
template<typename _RandomAccessIterator, typename _Distance,
typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__chunk_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last,
* is the largest of the set, the smallest is generated and false returned.
*/
template<typename _BidirectionalIterator>
+ _GLIBCXX20_CONSTEXPR
inline bool
next_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last)
* smallest is generated and false returned.
*/
template<typename _BidirectionalIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline bool
next_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last, _Compare __comp)
* returned.
*/
template<typename _BidirectionalIterator>
+ _GLIBCXX20_CONSTEXPR
inline bool
prev_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last)
* the largest is generated and false returned.
*/
template<typename _BidirectionalIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline bool
prev_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last, _Compare __comp)
* @p stable_partition() if this is needed.
*/
template<typename _ForwardIterator, typename _Predicate>
+ _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
partition(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
* the range @p [__middle,__last) then *j<*i and *k<*i are both false.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
partial_sort(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
* are both false.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
partial_sort(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
* holds that *j < *i is false.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
_RandomAccessIterator __last)
* holds that @p __comp(*j,*i) is false.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
_RandomAccessIterator __last, _Compare __comp)
* @p stable_sort() if this is needed.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
* @p stable_sort() if this is needed.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
struct __iter_swap
{
template<typename _ForwardIterator1, typename _ForwardIterator2>
+ _GLIBCXX20_CONSTEXPR
static void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
{
struct __iter_swap<true>
{
template<typename _ForwardIterator1, typename _ForwardIterator2>
+ _GLIBCXX20_CONSTEXPR
static void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
{
* iterators themselves.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
+ _GLIBCXX20_CONSTEXPR
inline void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
{
* The ranges must not overlap.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
+ _GLIBCXX20_CONSTEXPR
_ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2)
template<typename _RandomAccessIterator, typename _Distance, typename _Tp,
typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__push_heap(_RandomAccessIterator __first,
_Distance __holeIndex, _Distance __topIndex, _Tp __value,
* [__first,__last) is a valid heap.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
* performed using comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
template<typename _RandomAccessIterator, typename _Distance,
typename _Tp, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
_Distance __len, _Tp __value, _Compare __comp)
}
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_RandomAccessIterator __result, _Compare& __comp)
* heap.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
* heap. Comparisons are made using comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
pop_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
}
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare& __comp)
* This operation makes the elements in [__first,__last) into a heap.
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
* Comparisons are made using __comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
}
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare& __comp)
* This operation sorts the valid heap in the range [__first,__last).
*/
template<typename _RandomAccessIterator>
+ _GLIBCXX20_CONSTEXPR
inline void
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
* Comparisons are made using __comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
inline void
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{ };
template<typename _Tp>
+ _GLIBCXX20_CONSTEXPR
inline
typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
is_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>::value);
template<typename _Tp, size_t _Nm>
+ _GLIBCXX20_CONSTEXPR
inline
typename enable_if<__is_swappable<_Tp>::value>::type
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
#define __cpp_lib_bind_front 201907L
#define __cpp_lib_bounded_array_traits 201902L
#define __cpp_lib_constexpr_algorithms 201711L
+#define __cpp_lib_constexpr_swap_algorithms 201806L
#if __cpp_impl_destroying_delete
# define __cpp_lib_destroying_delete 201806L
#endif
// 25.2.2, swap:
#if __cplusplus < 201103L
template<typename _Tp>
+ _GLIBCXX20_CONSTEXPR
void
swap(_Tp&, _Tp& b);
template<typename _Tp, size_t _Nm>
+ _GLIBCXX20_CONSTEXPR
void
swap(_Tp (&)[_Nm], _Tp (&)[_Nm]);
#else
#endif
template<typename _FIter1, typename _FIter2>
+ _GLIBCXX20_CONSTEXPR
_FIter2
swap_ranges(_FIter1 first1, _FIter1, _FIter2);
template<typename _FIter1, typename _FIter2>
+ _GLIBCXX20_CONSTEXPR
void
iter_swap(_FIter1, _FIter2 b);
unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate);
template<typename _BIter>
+ _GLIBCXX20_CONSTEXPR
void
reverse(_BIter, _BIter);
reverse_copy(_BIter, _BIter, _OIter);
template<typename _FIter>
+ _GLIBCXX20_CONSTEXPR
void
rotate(_FIter, _FIter, _FIter);
// 25.2.12, partitions:
template<typename _BIter, typename _Predicate>
+ _GLIBCXX20_CONSTEXPR
_BIter
partition(_BIter, _BIter, _Predicate);
// 25.3, sorting and related operations:
// 25.3.1, sorting:
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
sort(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
sort(_RAIter, _RAIter, _Compare);
stable_sort(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
partial_sort(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _IIter, typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
_RAIter
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter);
template<typename _IIter, typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
_RAIter
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
nth_element(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
nth_element(_RAIter, _RAIter, _RAIter, _Compare);
// 25.3.6, heap operations:
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
push_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
push_heap(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
pop_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
pop_heap(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
make_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
make_heap(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
+ _GLIBCXX20_CONSTEXPR
void
sort_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
void
sort_heap(_RAIter, _RAIter, _Compare);
// 25.3.9, permutations
template<typename _BIter>
+ _GLIBCXX20_CONSTEXPR
bool
next_permutation(_BIter, _BIter);
template<typename _BIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
bool
next_permutation(_BIter, _BIter, _Compare);
template<typename _BIter>
+ _GLIBCXX20_CONSTEXPR
bool
prev_permutation(_BIter, _BIter);
template<typename _BIter, typename _Compare>
+ _GLIBCXX20_CONSTEXPR
bool
prev_permutation(_BIter, _BIter, _Compare);
}
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+
+ std::iter_swap(ar0.begin() + 2, ar0.begin() + 5);
+
+ return ok = ar0[2] == 5 && ar0[5] == 2;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 23>
+ ah{{0,
+ 1, 2,
+ 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}};
+
+ std::make_heap(ah.begin(), ah.begin() + 17);
+ ok = ok && std::is_heap(ah.begin(), ah.begin() + 17);
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+
+ std::next_permutation(ar0.begin(), ar0.end());
+
+ return ok = ar0[11] == 10 && ar0[10] == 11;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+
+ std::nth_element(ar0.begin(), ar0.begin() + 5, ar0.end());
+ ok = ok && ar0[5] == 5;
+
+ std::sort(ar0.begin(), ar0.end(), std::greater<>());
+ std::nth_element(ar0.begin(), ar0.begin() + 5, ar0.end(), std::greater<>());
+ ok = ok && ar0[5] == 6;
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 7, 8, 9, 2, 3, 4, 5, 6, 10, 11}};
+
+ std::partial_sort(ar0.begin(), ar0.begin() + 5, ar0.end());
+ ok = ok && ar0[0] == 0 && ar0[4] == 4;
+
+ std::partial_sort(ar0.begin(), ar0.begin() + 5, ar0.end(), std::greater<>());
+ ok = ok && ar0[0] == 11 && ar0[4] == 7;
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ const std::array<int, 12> ar0{{0, 7, 8, 9, 1, 2, 5, 6, 10, 3, 4, 11}};
+ std::array<int, 12> or0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
+
+ std::partial_sort_copy(ar0.begin() + 5, ar0.begin() + 10,
+ or0.begin(), or0.begin() + 5);
+
+ std::partial_sort_copy(ar0.begin() + 5, ar0.begin() + 10,
+ or0.begin(), or0.begin() + 5, std::greater<>());
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{10, 0, 5, 1, 2, 6, 7, 8, 3, 4, 9, 11}};
+
+ auto iter1 = std::partition(ar0.begin(), ar0.end(),
+ [](int i){ return i < 7; });
+ ok = ok && *iter1 == 8;
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 23>
+ ah{{0,
+ 1, 2,
+ 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}};
+
+ std::make_heap(ah.begin(), ah.end());
+ ok = ok && std::is_heap(ah.begin(), ah.end());
+
+ std::pop_heap(ah.begin(), ah.end());
+ std::pop_heap(ah.begin(), ah.end() - 1);
+ std::pop_heap(ah.begin(), ah.end() - 2);
+ ok = ok && std::is_heap(ah.begin(), ah.end() - 3)
+ && !std::is_heap(ah.begin(), ah.end());
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+
+ std::prev_permutation(ar0.begin(), ar0.end());
+
+ return ok = ar0[0] == 0;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 23>
+ ah{{0,
+ 1, 2,
+ 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}};
+
+ std::make_heap(ah.begin(), ah.end() - 3);
+ ok = ok && std::is_heap(ah.begin(), ah.end() - 3);
+
+ std::push_heap(ah.begin(), ah.end() - 2);
+ std::push_heap(ah.begin(), ah.end() - 1);
+ std::push_heap(ah.begin(), ah.end());
+ ok = ok && std::is_heap(ah.begin(), ah.end());
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+
+ std::reverse(ar0.begin() + 2, ar0.begin() + 9);
+
+ return ar0[2] == 8 && ar0[8] == 2;
+}
+
+static_assert(test());
--- /dev/null
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+
+ std::rotate(ar0.begin(), ar0.begin() + 5, ar0.end());
+
+ return ar0[0] == 5 && ar0[5] == 10;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{10, 0, 1, 2, 5, 6, 7, 8, 3, 4, 9, 11}};
+
+ std::sort(ar0.begin(), ar0.end());
+ ok = ok && std::is_sorted(ar0.begin(), ar0.end());
+
+ std::sort(ar0.begin(), ar0.end(), std::greater<>());
+ ok = ok && std::is_sorted(ar0.begin(), ar0.end(), std::greater<>());
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 23>
+ ah{{0,
+ 1, 2,
+ 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}};
+
+ std::make_heap(ah.begin(), ah.begin() + 17);
+ ok = ok && std::is_heap(ah.begin(), ah.begin() + 17);
+
+ std::sort_heap(ah.begin(), ah.begin() + 17);
+ ok = ok && std::is_sorted(ah.begin(), ah.begin() + 17);
+
+ std::make_heap(ah.begin(), ah.begin() + 17, std::greater<>());
+ ok = ok && std::is_heap(ah.begin(), ah.begin() + 17, std::greater<>());
+
+ std::sort_heap(ah.begin(), ah.begin() + 17, std::greater<>());
+ ok = ok && std::is_sorted(ah.begin(), ah.begin() + 17, std::greater<>());
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ double asc = 3.1415;
+ double bsc = 2.7182;
+ std::swap(asc, bsc);
+ ok = ok && asc == 2.7182 && bsc == 3.1415;
+
+ float arr[5]{0.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ float brr[5]{5.0f, 6.0f, 7.0f, 8.0f, 9.0f};
+ std::swap(arr, brr);
+ ok = ok && arr[2] == 7.0f && brr[2] == 2.0f;
+
+ return ok;
+}
+
+static_assert(test());
--- /dev/null
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <algorithm>
+#include <array>
+
+#ifndef __cpp_lib_constexpr_swap_algorithms
+# error "Feature-test macro for constexpr swap algorithms missing"
+#elif __cpp_lib_constexpr_swap_algorithms < 201806L
+# error "Feature-test macro for constexpr swap algorithms has wrong value"
+#endif
+
+constexpr bool
+test()
+{
+ auto ok = true;
+
+ std::array<int, 12> ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
+ std::array<int, 12> ar1{{11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}};
+
+ const auto out01 = std::swap_ranges(ar0.begin(), ar0.begin() + 5,
+ ar1.begin() + 2);
+
+ return ok = ar0[0] == 9 && ar1[2] == 0;
+}
+
+static_assert(test());