From: Edward Smith-Rowland <3dw4rd@verizon.net> Date: Thu, 1 Aug 2019 15:25:42 +0000 (+0000) Subject: Implement C++20 p0202 - Add Constexpr Modifiers to Functions in and ... X-Git-Tag: upstream/12.2.0~22829 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a66e68ad92f7b4150e35e20e2bb22f777837b63;p=platform%2Fupstream%2Fgcc.git Implement C++20 p0202 - Add Constexpr Modifiers to Functions in and Headers. 2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net> Implement C++20 p0202 - Add Constexpr Modifiers to Functions in and Headers. Implement C++20 p1023 - constexpr comparison operators for std::array. * include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy, copy_backward, copy_if, copy_n, equal_range, fill, find_end, find_if_not, includes, is_heap, is_heap_until, is_partitioned, is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound, none_of, partition_copy, partition_point, remove, remove_if, remove_copy, remove_copy_if, replace_copy, replace_copy_if, reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count, count_if, equal, find, find_first_of, find_if, for_each, generate, generate_n, lexicographical_compare, merge, mismatch, replace, replace_if, search, search_n, set_difference, set_intersection, set_symmetric_difference, set_union, transform, unique_copy): Mark constexpr. * include/bits/cpp_type_traits.h (__miter_base): Mark constexpr. * include/bits/predefined_ops.h (_Iter_less_val::operator(), _Val_less_iter::operator(), _Iter_equal_to_iter::operator(), _Iter_equal_to_val::operator(), _Iter_equals_val::operator()): Use const ref instead of ref arg; (_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter, __iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val, _Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val, _Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter, _Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter, __iter_comp_iter): Mark constexpr. * include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n, __search, __search_n_aux, __search_n, __find_end, find_end, all_of, none_of, any_of, find_if_not, is_partitioned, partition_point, __remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n, copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find, __unique, unique, __unique_copy, reverse_copy, rotate_copy, __unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort, __final_insertion_sort, lower_bound, __upper_bound, upper_bound, __equal_range, equal_range, binary_search, __includes, includes, __next_permutation, __prev_permutation, __replace_copy_if, replace_copy, replace_copy_if, __count_if, is_sorted, __is_sorted_until, is_sorted_until, __is_permutation, is_permutation, for_each, find, find_if, find_first_of, adjacent_find, count, count_if, search, search_n, transform, replace, replace_if, generate, generate_n, unique_copy, __merge, merge, __set_union, set_union, __set_intersection, set_intersection, __set_difference, set_difference, __set_symmetric_difference, set_symmetric_difference): Mark constexpr. * include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr wrappers around __builtin_memmove and __builtin_memcmp respectively; (__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2, copy, move, __copy_move_b, __copy_move_backward_a, __copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill, __fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2, __lexicographical_compare_impl, __lexicographical_compare, __lexicographical_compare::__lc, __lexicographical_compare_aux, __lower_bound, lower_bound, equal, __equal4, lexicographical_compare, __mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until, is_heap): Mark constexpr. * include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until, is_heap): Mark constexpr. * include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr. * include/std/array: Make comparison ops constexpr. * include/std/utility: Make exchange constexpr. * include/std/version (__cpp_lib_constexpr_algorithms): New macro. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust. * testsuite/23_containers/array/tuple_interface/ tuple_element_neg.cc: Adjust. * testsuite/20_util/exchange/constexpr.cc: New. * testsuite/23_containers/array/comparison_operators/constexpr.cc: New. * testsuite/25_algorithms/constexpr_macro.cc: New. * testsuite/25_algorithms/adjacent_find/constexpr.cc: New. * testsuite/25_algorithms/all_of/constexpr.cc: New. * testsuite/25_algorithms/any_of/constexpr.cc: New. * testsuite/25_algorithms/binary_search/constexpr.cc: New. * testsuite/25_algorithms/copy/constexpr.cc: New. * testsuite/25_algorithms/copy_backward/constexpr.cc: New. * testsuite/25_algorithms/copy_if/constexpr.cc: New. * testsuite/25_algorithms/copy_n/constexpr.cc: New. * testsuite/25_algorithms/count/constexpr.cc: New. * testsuite/25_algorithms/count_if/constexpr.cc: New. * testsuite/25_algorithms/equal/constexpr.cc: New. * testsuite/25_algorithms/equal_range/constexpr.cc: New. * testsuite/25_algorithms/fill/constexpr.cc: New. * testsuite/25_algorithms/fill_n/constexpr.cc: New. * testsuite/25_algorithms/find/constexpr.cc: New. * testsuite/25_algorithms/find_end/constexpr.cc: New. * testsuite/25_algorithms/find_first_of/constexpr.cc: New. * testsuite/25_algorithms/find_if/constexpr.cc: New. * testsuite/25_algorithms/find_if_not/constexpr.cc: New. * testsuite/25_algorithms/for_each/constexpr.cc: New. * testsuite/25_algorithms/generate/constexpr.cc: New. * testsuite/25_algorithms/generate_n/constexpr.cc: New. * testsuite/25_algorithms/is_heap/constexpr.cc: New. * testsuite/25_algorithms/is_heap_until/constexpr.cc: New. * testsuite/25_algorithms/is_partitioned/constexpr.cc: New. * testsuite/25_algorithms/is_permutation/constexpr.cc: New. * testsuite/25_algorithms/is_sorted/constexpr.cc: New. * testsuite/25_algorithms/is_sorted_until/constexpr.cc: New. * testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New. * testsuite/25_algorithms/lower_bound/constexpr.cc: New. * testsuite/25_algorithms/merge/constexpr.cc: New. * testsuite/25_algorithms/mismatch/constexpr.cc: New. * testsuite/25_algorithms/none_of/constexpr.cc: New. * testsuite/25_algorithms/partition_copy/constexpr.cc: New. * testsuite/25_algorithms/partition_point/constexpr.cc: New. * testsuite/25_algorithms/remove/constexpr.cc: New. * testsuite/25_algorithms/remove_copy/constexpr.cc: New. * testsuite/25_algorithms/remove_copy_if/constexpr.cc: New. * testsuite/25_algorithms/remove_if/constexpr.cc: New. * testsuite/25_algorithms/replace_copy/constexpr.cc: New. * testsuite/25_algorithms/replace_copy_if/constexpr.cc: New. * testsuite/25_algorithms/replace_if/constexpr.cc: New. * testsuite/25_algorithms/reverse_copy/constexpr.cc: New. * testsuite/25_algorithms/rotate_copy/constexpr.cc: New. * testsuite/25_algorithms/search/constexpr.cc: New. * testsuite/25_algorithms/search_n/constexpr.cc: New. * testsuite/25_algorithms/set_difference/constexpr.cc: New. * testsuite/25_algorithms/set_intersection/constexpr.cc: New. * testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New. * testsuite/25_algorithms/set_union/constexpr.cc: New. * testsuite/25_algorithms/transform/constexpr.cc: New. * testsuite/25_algorithms/unique/constexpr.cc: New. * testsuite/25_algorithms/unique_copy/constexpr.cc: New. * testsuite/25_algorithms/upper_bound/constexpr.cc: New. From-SVN: r273975 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e213f17..670e99b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,127 @@ +2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net> + + Implement C++20 p0202 - Add Constexpr Modifiers to Functions + in and Headers. + Implement C++20 p1023 - constexpr comparison operators for std::array. + * include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy, + copy_backward, copy_if, copy_n, equal_range, fill, find_end, + find_if_not, includes, is_heap, is_heap_until, is_partitioned, + is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound, + none_of, partition_copy, partition_point, remove, remove_if, + remove_copy, remove_copy_if, replace_copy, replace_copy_if, + reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count, + count_if, equal, find, find_first_of, find_if, for_each, generate, + generate_n, lexicographical_compare, merge, mismatch, replace, + replace_if, search, search_n, set_difference, set_intersection, + set_symmetric_difference, set_union, transform, unique_copy): + Mark constexpr. + * include/bits/cpp_type_traits.h (__miter_base): Mark constexpr. + * include/bits/predefined_ops.h (_Iter_less_val::operator(), + _Val_less_iter::operator(), _Iter_equal_to_iter::operator(), + _Iter_equal_to_val::operator(), _Iter_equals_val::operator()): + Use const ref instead of ref arg; + (_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter, + __iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val, + _Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val, + _Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter, + _Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter, + __iter_comp_iter): Mark constexpr. + * include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n, + __search, __search_n_aux, __search_n, __find_end, find_end, all_of, + none_of, any_of, find_if_not, is_partitioned, partition_point, + __remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n, + copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find, + __unique, unique, __unique_copy, reverse_copy, rotate_copy, + __unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort, + __final_insertion_sort, lower_bound, __upper_bound, upper_bound, + __equal_range, equal_range, binary_search, __includes, includes, + __next_permutation, __prev_permutation, __replace_copy_if, replace_copy, + replace_copy_if, __count_if, is_sorted, __is_sorted_until, + is_sorted_until, __is_permutation, is_permutation, for_each, find, + find_if, find_first_of, adjacent_find, count, count_if, search, + search_n, transform, replace, replace_if, generate, generate_n, + unique_copy, __merge, merge, __set_union, set_union, __set_intersection, + set_intersection, __set_difference, set_difference, + __set_symmetric_difference, set_symmetric_difference): Mark constexpr. + * include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr + wrappers around __builtin_memmove and __builtin_memcmp + respectively; + (__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2, + copy, move, __copy_move_b, __copy_move_backward_a, + __copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill, + __fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2, + __lexicographical_compare_impl, __lexicographical_compare, + __lexicographical_compare::__lc, __lexicographical_compare_aux, + __lower_bound, lower_bound, equal, __equal4, lexicographical_compare, + __mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until, + is_heap): Mark constexpr. + * include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until, + is_heap): Mark constexpr. + * include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr. + * include/std/array: Make comparison ops constexpr. + * include/std/utility: Make exchange constexpr. + * include/std/version (__cpp_lib_constexpr_algorithms): New macro. + * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust. + * testsuite/23_containers/array/tuple_interface/ + tuple_element_neg.cc: Adjust. + * testsuite/20_util/exchange/constexpr.cc: New. + * testsuite/23_containers/array/comparison_operators/constexpr.cc: New. + * testsuite/25_algorithms/constexpr_macro.cc: New. + * testsuite/25_algorithms/adjacent_find/constexpr.cc: New. + * testsuite/25_algorithms/all_of/constexpr.cc: New. + * testsuite/25_algorithms/any_of/constexpr.cc: New. + * testsuite/25_algorithms/binary_search/constexpr.cc: New. + * testsuite/25_algorithms/copy/constexpr.cc: New. + * testsuite/25_algorithms/copy_backward/constexpr.cc: New. + * testsuite/25_algorithms/copy_if/constexpr.cc: New. + * testsuite/25_algorithms/copy_n/constexpr.cc: New. + * testsuite/25_algorithms/count/constexpr.cc: New. + * testsuite/25_algorithms/count_if/constexpr.cc: New. + * testsuite/25_algorithms/equal/constexpr.cc: New. + * testsuite/25_algorithms/equal_range/constexpr.cc: New. + * testsuite/25_algorithms/fill/constexpr.cc: New. + * testsuite/25_algorithms/fill_n/constexpr.cc: New. + * testsuite/25_algorithms/find/constexpr.cc: New. + * testsuite/25_algorithms/find_end/constexpr.cc: New. + * testsuite/25_algorithms/find_first_of/constexpr.cc: New. + * testsuite/25_algorithms/find_if/constexpr.cc: New. + * testsuite/25_algorithms/find_if_not/constexpr.cc: New. + * testsuite/25_algorithms/for_each/constexpr.cc: New. + * testsuite/25_algorithms/generate/constexpr.cc: New. + * testsuite/25_algorithms/generate_n/constexpr.cc: New. + * testsuite/25_algorithms/is_heap/constexpr.cc: New. + * testsuite/25_algorithms/is_heap_until/constexpr.cc: New. + * testsuite/25_algorithms/is_partitioned/constexpr.cc: New. + * testsuite/25_algorithms/is_permutation/constexpr.cc: New. + * testsuite/25_algorithms/is_sorted/constexpr.cc: New. + * testsuite/25_algorithms/is_sorted_until/constexpr.cc: New. + * testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New. + * testsuite/25_algorithms/lower_bound/constexpr.cc: New. + * testsuite/25_algorithms/merge/constexpr.cc: New. + * testsuite/25_algorithms/mismatch/constexpr.cc: New. + * testsuite/25_algorithms/none_of/constexpr.cc: New. + * testsuite/25_algorithms/partition_copy/constexpr.cc: New. + * testsuite/25_algorithms/partition_point/constexpr.cc: New. + * testsuite/25_algorithms/remove/constexpr.cc: New. + * testsuite/25_algorithms/remove_copy/constexpr.cc: New. + * testsuite/25_algorithms/remove_copy_if/constexpr.cc: New. + * testsuite/25_algorithms/remove_if/constexpr.cc: New. + * testsuite/25_algorithms/replace_copy/constexpr.cc: New. + * testsuite/25_algorithms/replace_copy_if/constexpr.cc: New. + * testsuite/25_algorithms/replace_if/constexpr.cc: New. + * testsuite/25_algorithms/reverse_copy/constexpr.cc: New. + * testsuite/25_algorithms/rotate_copy/constexpr.cc: New. + * testsuite/25_algorithms/search/constexpr.cc: New. + * testsuite/25_algorithms/search_n/constexpr.cc: New. + * testsuite/25_algorithms/set_difference/constexpr.cc: New. + * testsuite/25_algorithms/set_intersection/constexpr.cc: New. + * testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New. + * testsuite/25_algorithms/set_union/constexpr.cc: New. + * testsuite/25_algorithms/transform/constexpr.cc: New. + * testsuite/25_algorithms/unique/constexpr.cc: New. + * testsuite/25_algorithms/unique_copy/constexpr.cc: New. + * testsuite/25_algorithms/upper_bound/constexpr.cc: New. + 2019-07-31 Jonathan Wakely * include/std/memory (make_obj_using_allocator): Qualify call to diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 5e47fff..99491db 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -191,21 +191,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // adjacent_find +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_algorithms 201711L +#endif + #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR bool all_of(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR bool any_of(_IIter, _IIter, _Predicate); #endif template + _GLIBCXX20_CONSTEXPR bool binary_search(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR bool binary_search(_FIter, _FIter, const _Tp&, _Compare); @@ -222,19 +230,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template + _GLIBCXX20_CONSTEXPR _OIter copy(_IIter, _IIter, _OIter); template + _GLIBCXX20_CONSTEXPR _BIter2 copy_backward(_BIter1, _BIter1, _BIter2); #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR _OIter copy_if(_IIter, _IIter, _OIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _OIter copy_n(_IIter, _Size, _OIter); #endif @@ -243,28 +255,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // count_if template + _GLIBCXX20_CONSTEXPR pair<_FIter, _FIter> equal_range(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR pair<_FIter, _FIter> equal_range(_FIter, _FIter, const _Tp&, _Compare); template + _GLIBCXX20_CONSTEXPR void fill(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _OIter fill_n(_OIter, _Size, const _Tp&); // find template + _GLIBCXX20_CONSTEXPR _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); @@ -273,6 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR _IIter find_if_not(_IIter, _IIter, _Predicate); #endif @@ -282,10 +301,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // generate_n template + _GLIBCXX20_CONSTEXPR bool includes(_IIter1, _IIter1, _IIter2, _IIter2); template + _GLIBCXX20_CONSTEXPR bool includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); @@ -299,47 +320,58 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR bool is_heap(_RAIter, _RAIter); template + _GLIBCXX20_CONSTEXPR bool is_heap(_RAIter, _RAIter, _Compare); template + _GLIBCXX20_CONSTEXPR _RAIter is_heap_until(_RAIter, _RAIter); template + _GLIBCXX20_CONSTEXPR _RAIter is_heap_until(_RAIter, _RAIter, _Compare); template + _GLIBCXX20_CONSTEXPR bool is_partitioned(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR bool is_permutation(_FIter1, _FIter1, _FIter2); template + _GLIBCXX20_CONSTEXPR bool is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR bool is_sorted(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR bool is_sorted(_FIter, _FIter, _Compare); template + _GLIBCXX20_CONSTEXPR _FIter is_sorted_until(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _FIter is_sorted_until(_FIter, _FIter, _Compare); #endif @@ -349,10 +381,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION iter_swap(_FIter1, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter lower_bound(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter lower_bound(_FIter, _FIter, const _Tp&, _Compare); @@ -453,6 +487,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR bool none_of(_IIter, _IIter, _Predicate); #endif @@ -473,10 +508,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR pair<_OIter1, _OIter2> partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); template + _GLIBCXX20_CONSTEXPR _FIter partition_point(_FIter, _FIter, _Predicate); #endif @@ -508,28 +545,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // random_shuffle template + _GLIBCXX20_CONSTEXPR _FIter remove(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter remove_if(_FIter, _FIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _OIter remove_copy(_IIter, _IIter, _OIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _OIter remove_copy_if(_IIter, _IIter, _OIter, _Predicate); // replace template + _GLIBCXX20_CONSTEXPR _OIter replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); template + _GLIBCXX20_CONSTEXPR _OIter replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); @@ -540,6 +583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION reverse(_BIter, _BIter); template + _GLIBCXX20_CONSTEXPR _OIter reverse_copy(_BIter, _BIter, _OIter); @@ -551,6 +595,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR _OIter rotate_copy(_FIter, _FIter, _FIter, _OIter); @@ -598,82 +643,101 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // transform template + _GLIBCXX20_CONSTEXPR _FIter unique(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _FIter unique(_FIter, _FIter, _BinaryPredicate); // unique_copy template + _GLIBCXX20_CONSTEXPR _FIter upper_bound(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter upper_bound(_FIter, _FIter, const _Tp&, _Compare); _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR _FIter adjacent_find(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _FIter adjacent_find(_FIter, _FIter, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR typename iterator_traits<_IIter>::difference_type count(_IIter, _IIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR typename iterator_traits<_IIter>::difference_type count_if(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR bool equal(_IIter1, _IIter1, _IIter2); template + _GLIBCXX20_CONSTEXPR bool equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _IIter find(_IIter, _IIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter1 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter1 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _IIter find_if(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _Funct for_each(_IIter, _IIter, _Funct); template + _GLIBCXX20_CONSTEXPR void generate(_FIter, _FIter, _Generator); template + _GLIBCXX20_CONSTEXPR _OIter generate_n(_OIter, _Size, _Generator); template + _GLIBCXX20_CONSTEXPR bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); template + _GLIBCXX20_CONSTEXPR bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); @@ -688,11 +752,13 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO max_element(_FIter, _FIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); @@ -707,10 +773,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO min_element(_FIter, _FIter, _Compare); template + _GLIBCXX20_CONSTEXPR pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2); template + _GLIBCXX20_CONSTEXPR pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); @@ -748,64 +816,78 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO #endif template + _GLIBCXX20_CONSTEXPR void replace(_FIter, _FIter, const _Tp&, const _Tp&); template + _GLIBCXX20_CONSTEXPR void replace_if(_FIter, _FIter, _Predicate, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _FIter search_n(_FIter, _FIter, _Size, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); @@ -826,19 +908,23 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO stable_sort(_RAIter, _RAIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter transform(_IIter, _IIter, _OIter, _UnaryOperation); template + _GLIBCXX20_CONSTEXPR _OIter transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); template + _GLIBCXX20_CONSTEXPR _OIter unique_copy(_IIter, _IIter, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index d7f8517..3e165c7 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -424,6 +424,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // Fallback implementation of the function in bits/stl_iterator.h used to // remove the move_iterator wrapper. template + _GLIBCXX20_CONSTEXPR inline _Iterator __miter_base(_Iterator __it) { return __it; } diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index 7271e27..e3ddeb5 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -145,6 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // C++11 version of std::exchange for internal use. template + _GLIBCXX20_CONSTEXPR inline _Tp __exchange(_Tp& __obj, _Up&& __new_val) { diff --git a/libstdc++-v3/include/bits/predefined_ops.h b/libstdc++-v3/include/bits/predefined_ops.h index 65215c7..e39b76c 100644 --- a/libstdc++-v3/include/bits/predefined_ops.h +++ b/libstdc++-v3/include/bits/predefined_ops.h @@ -56,19 +56,23 @@ namespace __ops _Iter_less_val() { } #endif + _GLIBCXX20_CONSTEXPR explicit _Iter_less_val(_Iter_less_iter) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it, _Value& __val) const { return *__it < __val; } }; + _GLIBCXX20_CONSTEXPR inline _Iter_less_val __iter_less_val() { return _Iter_less_val(); } + _GLIBCXX20_CONSTEXPR inline _Iter_less_val __iter_comp_val(_Iter_less_iter) { return _Iter_less_val(); } @@ -81,19 +85,23 @@ namespace __ops _Val_less_iter() { } #endif + _GLIBCXX20_CONSTEXPR explicit _Val_less_iter(_Iter_less_iter) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Value& __val, _Iterator __it) const { return __val < *__it; } }; + _GLIBCXX20_CONSTEXPR inline _Val_less_iter __val_less_iter() { return _Val_less_iter(); } + _GLIBCXX20_CONSTEXPR inline _Val_less_iter __val_comp_iter(_Iter_less_iter) { return _Val_less_iter(); } @@ -101,11 +109,13 @@ namespace __ops struct _Iter_equal_to_iter { template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator1 __it1, _Iterator2 __it2) const { return *__it1 == *__it2; } }; + _GLIBCXX20_CONSTEXPR inline _Iter_equal_to_iter __iter_equal_to_iter() { return _Iter_equal_to_iter(); } @@ -113,15 +123,18 @@ namespace __ops struct _Iter_equal_to_val { template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it, _Value& __val) const { return *__it == __val; } }; + _GLIBCXX20_CONSTEXPR inline _Iter_equal_to_val __iter_equal_to_val() { return _Iter_equal_to_val(); } + _GLIBCXX20_CONSTEXPR inline _Iter_equal_to_val __iter_comp_val(_Iter_equal_to_iter) { return _Iter_equal_to_val(); } @@ -154,17 +167,20 @@ namespace __ops { _Compare _M_comp; + _GLIBCXX20_CONSTEXPR explicit _Iter_comp_val(_Compare __comp) : _M_comp(_GLIBCXX_MOVE(__comp)) { } + _GLIBCXX20_CONSTEXPR explicit _Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp) : _M_comp(__comp._M_comp) { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR explicit _Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp) : _M_comp(std::move(__comp._M_comp)) @@ -172,17 +188,20 @@ namespace __ops #endif template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it, _Value& __val) { return bool(_M_comp(*__it, __val)); } }; template - inline _Iter_comp_val<_Compare> + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_val<_Compare> __iter_comp_val(_Compare __comp) { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); } template + _GLIBCXX20_CONSTEXPR inline _Iter_comp_val<_Compare> __iter_comp_val(_Iter_comp_iter<_Compare> __comp) { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); } @@ -192,17 +211,20 @@ namespace __ops { _Compare _M_comp; + _GLIBCXX20_CONSTEXPR explicit _Val_comp_iter(_Compare __comp) : _M_comp(_GLIBCXX_MOVE(__comp)) { } + _GLIBCXX20_CONSTEXPR explicit _Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp) : _M_comp(__comp._M_comp) { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR explicit _Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp) : _M_comp(std::move(__comp._M_comp)) @@ -210,17 +232,20 @@ namespace __ops #endif template + _GLIBCXX20_CONSTEXPR bool operator()(_Value& __val, _Iterator __it) { return bool(_M_comp(__val, *__it)); } }; template + _GLIBCXX20_CONSTEXPR inline _Val_comp_iter<_Compare> __val_comp_iter(_Compare __comp) { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } template + _GLIBCXX20_CONSTEXPR inline _Val_comp_iter<_Compare> __val_comp_iter(_Iter_comp_iter<_Compare> __comp) { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } @@ -230,18 +255,21 @@ namespace __ops { _Value& _M_value; + _GLIBCXX20_CONSTEXPR explicit _Iter_equals_val(_Value& __value) : _M_value(__value) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it) { return *__it == _M_value; } }; template + _GLIBCXX20_CONSTEXPR inline _Iter_equals_val<_Value> __iter_equals_val(_Value& __val) { return _Iter_equals_val<_Value>(__val); } @@ -251,18 +279,21 @@ namespace __ops { _Iterator1 _M_it1; + _GLIBCXX20_CONSTEXPR explicit _Iter_equals_iter(_Iterator1 __it1) : _M_it1(__it1) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator2 __it2) { return *__it2 == *_M_it1; } }; template + _GLIBCXX20_CONSTEXPR inline _Iter_equals_iter<_Iterator> __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it) { return _Iter_equals_iter<_Iterator>(__it); } @@ -272,18 +303,21 @@ namespace __ops { _Predicate _M_pred; + _GLIBCXX20_CONSTEXPR explicit _Iter_pred(_Predicate __pred) : _M_pred(_GLIBCXX_MOVE(__pred)) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it) { return bool(_M_pred(*__it)); } }; template + _GLIBCXX20_CONSTEXPR inline _Iter_pred<_Predicate> __pred_iter(_Predicate __pred) { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); } @@ -294,11 +328,13 @@ namespace __ops _Compare _M_comp; _Value& _M_value; + _GLIBCXX20_CONSTEXPR _Iter_comp_to_val(_Compare __comp, _Value& __value) : _M_comp(_GLIBCXX_MOVE(__comp)), _M_value(__value) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it) { return bool(_M_comp(*__it, _M_value)); } @@ -306,6 +342,7 @@ namespace __ops template _Iter_comp_to_val<_Compare, _Value> + _GLIBCXX20_CONSTEXPR __iter_comp_val(_Compare __comp, _Value &__val) { return _Iter_comp_to_val<_Compare, _Value>(_GLIBCXX_MOVE(__comp), __val); @@ -317,17 +354,20 @@ namespace __ops _Compare _M_comp; _Iterator1 _M_it1; + _GLIBCXX20_CONSTEXPR _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1) : _M_comp(_GLIBCXX_MOVE(__comp)), _M_it1(__it1) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator2 __it2) { return bool(_M_comp(*__it2, *_M_it1)); } }; template + _GLIBCXX20_CONSTEXPR inline _Iter_comp_to_iter<_Compare, _Iterator> __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it) { @@ -340,18 +380,21 @@ namespace __ops { _Predicate _M_pred; + _GLIBCXX20_CONSTEXPR explicit _Iter_negate(_Predicate __pred) : _M_pred(_GLIBCXX_MOVE(__pred)) { } template + _GLIBCXX20_CONSTEXPR bool operator()(_Iterator __it) { return !bool(_M_pred(*__it)); } }; template + _GLIBCXX20_CONSTEXPR inline _Iter_negate<_Predicate> __negate(_Iter_pred<_Predicate> __pred) { return _Iter_negate<_Predicate>(_GLIBCXX_MOVE(__pred._M_pred)); } diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index ac21c55..0d70725 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -97,6 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// This is an overload used by find algos for the Input Iterator case. template + _GLIBCXX20_CONSTEXPR inline _InputIterator __find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag) @@ -108,6 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// This is an overload used by find algos for the RAI case. template + _GLIBCXX20_CONSTEXPR _RandomAccessIterator __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, _Predicate __pred, random_access_iterator_tag) @@ -155,6 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR inline _Iterator __find_if(_Iterator __first, _Iterator __last, _Predicate __pred) { @@ -164,6 +167,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Provided for stable_partition to use. template + _GLIBCXX20_CONSTEXPR inline _InputIterator __find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) @@ -177,6 +181,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// remaining range length instead of comparing against an end /// iterator. template + _GLIBCXX20_CONSTEXPR _InputIterator __find_if_not_n(_InputIterator __first, _Distance& __len, _Predicate __pred) { @@ -201,6 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR _ForwardIterator1 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -217,7 +223,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); // General case. - _ForwardIterator2 __p; _ForwardIterator1 __current = __first1; for (;;) @@ -229,7 +234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__first1 == __last1) return __last1; - __p = __p1; + _ForwardIterator2 __p = __p1; __current = __first1; if (++__current == __last1) return __last1; @@ -253,6 +258,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR _ForwardIterator __search_n_aux(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, _UnaryPredicate __unary_pred, @@ -285,6 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR _RandomAccessIter __search_n_aux(_RandomAccessIter __first, _RandomAccessIter __last, _Integer __count, _UnaryPredicate __unary_pred, @@ -315,6 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, @@ -333,6 +341,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // find_end for forward iterators. template + _GLIBCXX20_CONSTEXPR _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -361,6 +370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // find_end for bidirectional iterators (much faster). template + _GLIBCXX20_CONSTEXPR _BidirectionalIterator1 __find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, @@ -421,6 +431,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * [__first1,__last1-(__last2-__first2)) */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -470,6 +481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -504,6 +516,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @p [__first,__last), and false otherwise. */ template + _GLIBCXX20_CONSTEXPR inline bool all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return __last == std::find_if_not(__first, __last, __pred); } @@ -521,6 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @p [__first,__last), and false otherwise. */ template + _GLIBCXX20_CONSTEXPR inline bool none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return __last == _GLIBCXX_STD_A::find_if(__first, __last, __pred); } @@ -539,6 +553,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * otherwise. */ template + _GLIBCXX20_CONSTEXPR inline bool any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return !std::none_of(__first, __last, __pred); } @@ -554,6 +569,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * such that @p __pred(*i) is false, or @p __last if no such iterator exists. */ template + _GLIBCXX20_CONSTEXPR inline _InputIterator find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) @@ -578,6 +594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * do not. */ template + _GLIBCXX20_CONSTEXPR inline bool is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) @@ -599,6 +616,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * and @p none_of(mid, __last, __pred) are both true. */ template + _GLIBCXX20_CONSTEXPR _ForwardIterator partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) @@ -615,13 +633,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _DistanceType; _DistanceType __len = std::distance(__first, __last); - _DistanceType __half; - _ForwardIterator __middle; while (__len > 0) { - __half = __len >> 1; - __middle = __first; + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; std::advance(__middle, __half); if (__pred(*__middle)) { @@ -638,6 +654,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR _OutputIterator __remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) @@ -666,6 +683,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * are copied is unchanged. */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value) @@ -699,6 +717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) @@ -733,6 +752,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR _OutputIterator copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) @@ -755,6 +775,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR _OutputIterator __copy_n(_InputIterator __first, _Size __n, _OutputIterator __result, input_iterator_tag) @@ -776,6 +797,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR inline _OutputIterator __copy_n(_RandomAccessIterator __first, _Size __n, _OutputIterator __result, random_access_iterator_tag) @@ -795,6 +817,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * optimizations such as unrolling). */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) { @@ -824,6 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR pair<_OutputIterator1, _OutputIterator2> partition_copy(_InputIterator __first, _InputIterator __last, _OutputIterator1 __out_true, _OutputIterator2 __out_false, @@ -856,6 +880,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template + _GLIBCXX20_CONSTEXPR _ForwardIterator __remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) @@ -892,6 +917,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * are still present, but their value is unspecified. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) @@ -925,6 +951,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * are still present, but their value is unspecified. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) @@ -941,6 +968,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR _ForwardIterator __adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) @@ -958,6 +986,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR _ForwardIterator __unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) @@ -991,6 +1020,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * are still present, but their value is unspecified. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last) { @@ -1021,6 +1051,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * are still present, but their value is unspecified. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) @@ -1045,6 +1076,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR _OutputIterator __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred, @@ -1074,6 +1106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR _OutputIterator __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred, @@ -1106,6 +1139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR _ForwardIterator __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __binary_pred, @@ -1203,6 +1237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * [__result,__result+(__last-__first)) must not overlap. */ template + _GLIBCXX20_CONSTEXPR _OutputIterator reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) @@ -1467,6 +1502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * for each @p n in the range @p [0,__last-__first). */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result) @@ -1816,6 +1852,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// This is a helper function for the sort routine. template + _GLIBCXX20_CONSTEXPR void __unguarded_linear_insert(_RandomAccessIterator __last, _Compare __comp) @@ -1835,6 +1872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// This is a helper function for the sort routine. template + _GLIBCXX20_CONSTEXPR void __insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) @@ -1858,6 +1896,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// This is a helper function for the sort routine. template + _GLIBCXX20_CONSTEXPR inline void __unguarded_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) @@ -1875,6 +1914,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// This is a helper function for the sort routine. template + _GLIBCXX20_CONSTEXPR void __final_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) @@ -2018,6 +2058,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the function used for the initial sort. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) @@ -2034,6 +2075,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR _ForwardIterator __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) @@ -2072,6 +2114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @ingroup binary_search_algorithms */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) @@ -2102,6 +2145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the function used for the initial sort. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) @@ -2119,6 +2163,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, @@ -2173,6 +2218,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * but does not actually call those functions. */ template + _GLIBCXX20_CONSTEXPR inline pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) @@ -2209,6 +2255,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * but does not actually call those functions. */ template + _GLIBCXX20_CONSTEXPR inline pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) @@ -2242,6 +2289,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * that, use std::find or a container's specialized find member functions. */ template + _GLIBCXX20_CONSTEXPR bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) @@ -2275,6 +2323,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the function used for the initial sort. */ template + _GLIBCXX20_CONSTEXPR bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) @@ -2778,6 +2827,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR bool __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -2816,6 +2866,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * returned. */ template + _GLIBCXX20_CONSTEXPR inline bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) @@ -2861,6 +2912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR inline bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -2895,6 +2947,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // max_element template + _GLIBCXX20_CONSTEXPR bool __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) @@ -2994,6 +3047,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR bool __prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) @@ -3098,6 +3152,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR _OutputIterator __replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, @@ -3126,6 +3181,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * equal to @p __old_value with @p __new_value. */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, @@ -3161,6 +3217,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, @@ -3180,6 +3237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR typename iterator_traits<_InputIterator>::difference_type __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -3199,6 +3257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @return True if the elements are sorted, false otherwise. */ template + _GLIBCXX20_CONSTEXPR inline bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) { return std::is_sorted_until(__first, __last) == __last; } @@ -3213,12 +3272,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @return True if the elements are sorted, false otherwise. */ template + _GLIBCXX20_CONSTEXPR inline bool is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { return std::is_sorted_until(__first, __last, __comp) == __last; } template + _GLIBCXX20_CONSTEXPR _ForwardIterator __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) @@ -3242,6 +3303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * for which the range [__first, i) is sorted. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { @@ -3266,6 +3328,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * for which the range [__first, i) is sorted. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) @@ -3484,6 +3547,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR bool __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) @@ -3532,6 +3596,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * returns true; otherwise, returns false. */ template + _GLIBCXX20_CONSTEXPR inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) @@ -3564,6 +3629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) @@ -3583,6 +3649,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201103L template + _GLIBCXX20_CONSTEXPR bool __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -3656,6 +3723,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * otherwise, returns false. */ template + _GLIBCXX20_CONSTEXPR inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -3684,6 +3752,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + _GLIBCXX20_CONSTEXPR inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -3866,6 +3935,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * If @p __f has a return value it is ignored. */ template + _GLIBCXX20_CONSTEXPR _Function for_each(_InputIterator __first, _InputIterator __last, _Function __f) { @@ -3920,6 +3990,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * such that @c *i == @p __val, or @p __last if no such iterator exists. */ template + _GLIBCXX20_CONSTEXPR inline _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __val) @@ -3944,6 +4015,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * such that @p __pred(*i) is true, or @p __last if no such iterator exists. */ template + _GLIBCXX20_CONSTEXPR inline _InputIterator find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) @@ -3975,6 +4047,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * otherwise returns @p __last1. */ template + _GLIBCXX20_CONSTEXPR _InputIterator find_first_of(_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2) @@ -4016,6 +4089,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR _InputIterator find_first_of(_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2, @@ -4047,6 +4121,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * or @p __last if no such iterator exists. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { @@ -4072,6 +4147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * exists. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) @@ -4097,6 +4173,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * for which @c *i == @p __value */ template + _GLIBCXX20_CONSTEXPR inline typename iterator_traits<_InputIterator>::difference_type count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { @@ -4120,6 +4197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * for which @p __pred(*i) is true. */ template + _GLIBCXX20_CONSTEXPR inline typename iterator_traits<_InputIterator>::difference_type count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -4160,6 +4238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * @p [__first1,__last1-(__last2-__first2)) */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -4200,6 +4279,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -4234,6 +4314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * equal to @p __val. */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp& __val) @@ -4268,6 +4349,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp& __val, @@ -4316,6 +4398,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR _OutputIterator transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __unary_op) @@ -4353,6 +4436,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR _OutputIterator transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, @@ -4385,6 +4469,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * @p __old_value then the assignment @c *i = @p __new_value is performed. */ template + _GLIBCXX20_CONSTEXPR void replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value) @@ -4417,6 +4502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * is true then the assignment @c *i = @p __new_value is performed. */ template + _GLIBCXX20_CONSTEXPR void replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value) @@ -4449,6 +4535,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * @p [__first,__last). */ template + _GLIBCXX20_CONSTEXPR void generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) @@ -4482,6 +4569,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO // DR 865. More algorithms that throw away information // DR 426. search_n(), fill_n(), and generate_n() with negative n template + _GLIBCXX20_CONSTEXPR _OutputIterator generate_n(_OutputIterator __first, _Size __n, _Generator __gen) { @@ -4519,6 +4607,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * Assignable? */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) @@ -4560,6 +4649,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, @@ -4898,6 +4988,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR _OutputIterator __merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -4942,6 +5033,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -4992,6 +5084,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5109,6 +5202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR _OutputIterator __set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5159,6 +5253,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5209,6 +5304,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5240,6 +5336,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR _OutputIterator __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5280,6 +5377,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5329,6 +5427,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5358,6 +5457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR _OutputIterator __set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5402,6 +5502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5453,6 +5554,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5482,6 +5584,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR _OutputIterator __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, @@ -5532,6 +5635,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -5583,6 +5687,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 58bfb6c..ab1ff51 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -77,6 +77,57 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + /* + * A constexpr wrapper for __builtin_memmove. + * @param __num The number of elements of type _Tp (not bytes). + */ + template + _GLIBCXX14_CONSTEXPR + inline void* + __memmove(_Tp* __dst, const _Tp* __src, size_t __num) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for(; __num > 0; --__num) + { + if constexpr (_IsMove) + *__dst = std::move(*__src); + else + *__dst = *__src; + ++__src; + ++__dst; + } + return __dst; + } + else +#endif + return __builtin_memmove(__dst, __src, sizeof(_Tp) * __num); + return __dst; + } + + /* + * A constexpr wrapper for __builtin_memcmp. + * @param __num The number of elements of type _Tp (not bytes). + */ + template + _GLIBCXX14_CONSTEXPR + inline int + __memcmp(const _Tp* __first1, const _Tp* __first2, size_t __num) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for(; __num > 0; ++__first1, ++__first2, --__num) + if (*__first1 != *__first2) + return *__first1 < *__first2 ? -1 : 1; + return 0; + } + else +#endif + return __builtin_memcmp(__first1, __first2, sizeof(_Tp) * __num); + } + #if __cplusplus < 201103L // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a // nutshell, we are partially implementing the resolution of DR 187, @@ -276,6 +327,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Fallback implementation of the function in bits/stl_iterator.h used to // remove the __normal_iterator wrapper. See copy, fill, ... template + _GLIBCXX20_CONSTEXPR inline _Iterator __niter_base(_Iterator __it) _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value) @@ -285,12 +337,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __normal_iterator back again (this assumes that __normal_iterator // is only used to wrap random access iterators, like pointers). template + _GLIBCXX20_CONSTEXPR inline _From __niter_wrap(_From __from, _To __res) { return __from + (__res - std::__niter_base(__from)); } // No need to wrap, iterator already has the right type. template + _GLIBCXX20_CONSTEXPR inline _Iterator __niter_wrap(const _Iterator&, _Iterator __res) { return __res; } @@ -305,6 +359,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move { template + _GLIBCXX20_CONSTEXPR static _OI __copy_m(_II __first, _II __last, _OI __result) { @@ -319,6 +374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move { template + _GLIBCXX20_CONSTEXPR static _OI __copy_m(_II __first, _II __last, _OI __result) { @@ -333,6 +389,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move { template + _GLIBCXX20_CONSTEXPR static _OI __copy_m(_II __first, _II __last, _OI __result) { @@ -352,6 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move { template + _GLIBCXX20_CONSTEXPR static _OI __copy_m(_II __first, _II __last, _OI __result) { @@ -371,6 +429,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move<_IsMove, true, random_access_iterator_tag> { template + _GLIBCXX20_CONSTEXPR static _Tp* __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result) { @@ -383,12 +442,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif const ptrdiff_t _Num = __last - __first; if (_Num) - __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); + std::__memmove<_IsMove>(__result, __first, _Num); return __result + _Num; } }; template + _GLIBCXX20_CONSTEXPR inline _OI __copy_move_a(_II __first, _II __last, _OI __result) { @@ -399,7 +459,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && __is_pointer<_II>::__value && __is_pointer<_OI>::__value && __are_same<_ValueTypeI, _ValueTypeO>::__value); - return std::__copy_move<_IsMove, __simple, _Category>::__copy_m(__first, __last, __result); } @@ -434,6 +493,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*); template + _GLIBCXX20_CONSTEXPR inline _OI __copy_move_a2(_II __first, _II __last, _OI __result) { @@ -461,6 +521,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * within [first,last). */ template + _GLIBCXX20_CONSTEXPR inline _OI copy(_II __first, _II __last, _OI __result) { @@ -493,6 +554,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * within [first,last). */ template + _GLIBCXX20_CONSTEXPR inline _OI move(_II __first, _II __last, _OI __result) { @@ -515,6 +577,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move_backward { template + _GLIBCXX20_CONSTEXPR static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { @@ -529,6 +592,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move_backward { template + _GLIBCXX20_CONSTEXPR static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { @@ -543,11 +607,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move_backward { template + _GLIBCXX20_CONSTEXPR static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { - typename iterator_traits<_BI1>::difference_type __n; - for (__n = __last - __first; __n > 0; --__n) + typename iterator_traits<_BI1>::difference_type + __n = __last - __first; + for (; __n > 0; --__n) *--__result = *--__last; return __result; } @@ -558,11 +624,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move_backward { template + _GLIBCXX20_CONSTEXPR static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { - typename iterator_traits<_BI1>::difference_type __n; - for (__n = __last - __first; __n > 0; --__n) + typename iterator_traits<_BI1>::difference_type + __n = __last - __first; + for (; __n > 0; --__n) *--__result = std::move(*--__last); return __result; } @@ -573,6 +641,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __copy_move_backward<_IsMove, true, random_access_iterator_tag> { template + _GLIBCXX20_CONSTEXPR static _Tp* __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) { @@ -585,12 +654,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif const ptrdiff_t _Num = __last - __first; if (_Num) - __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); + std::__memmove<_IsMove>(__result - _Num, __first, _Num); return __result - _Num; } }; template + _GLIBCXX20_CONSTEXPR inline _BI2 __copy_move_backward_a(_BI1 __first, _BI1 __last, _BI2 __result) { @@ -602,6 +672,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && __is_pointer<_BI2>::__value && __are_same<_ValueType1, _ValueType2>::__value); +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__copy_move_backward::__copy_move_b(__first, __last, + __result); +#endif return std::__copy_move_backward<_IsMove, __simple, _Category>::__copy_move_b(__first, __last, @@ -609,6 +685,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR inline _BI2 __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result) { @@ -637,6 +714,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * that the start of the output range may overlap [first,last). */ template + _GLIBCXX20_CONSTEXPR inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { @@ -672,6 +750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * that the start of the output range may overlap [first,last). */ template + _GLIBCXX20_CONSTEXPR inline _BI2 move_backward(_BI1 __first, _BI1 __last, _BI2 __result) { @@ -694,6 +773,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__enable_if::__value, void>::__type __fill_a(_ForwardIterator __first, _ForwardIterator __last, @@ -704,6 +784,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type __fill_a(_ForwardIterator __first, _ForwardIterator __last, @@ -738,6 +819,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * to @c memset or @c wmemset. */ template + _GLIBCXX20_CONSTEXPR inline void fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { @@ -801,6 +883,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__enable_if::__value, _OutputIterator>::__type __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value) @@ -814,6 +897,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value) @@ -828,6 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, _Tp*>::__type __fill_n_a(_Tp* __first, _Size __n, const _Tp& __c) @@ -854,6 +939,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // DR 865. More algorithms that throw away information // DR 426. search_n(), fill_n(), and generate_n() with negative n template + _GLIBCXX20_CONSTEXPR inline _OI fill_n(_OI __first, _Size __n, const _Tp& __value) { @@ -870,6 +956,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __equal { template + _GLIBCXX20_CONSTEXPR static bool equal(_II1 __first1, _II1 __last1, _II2 __first2) { @@ -884,16 +971,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __equal { template + _GLIBCXX20_CONSTEXPR static bool equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2) { if (const size_t __len = (__last1 - __first1)) - return !__builtin_memcmp(__first1, __first2, sizeof(_Tp) * __len); + return !std::__memcmp(__first1, __first2, __len); return true; } }; template + _GLIBCXX20_CONSTEXPR inline bool __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2) { @@ -912,11 +1001,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __lc_rai { template + _GLIBCXX20_CONSTEXPR static _II1 __newlast1(_II1, _II1 __last1, _II2, _II2) { return __last1; } template + _GLIBCXX20_CONSTEXPR static bool __cnd2(_II __first, _II __last) { return __first != __last; } @@ -926,6 +1017,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __lc_rai { template + _GLIBCXX20_CONSTEXPR static _RAI1 __newlast1(_RAI1 __first1, _RAI1 __last1, _RAI2 __first2, _RAI2 __last2) @@ -938,12 +1030,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - static bool + static _GLIBCXX20_CONSTEXPR bool __cnd2(_RAI, _RAI) { return true; } }; template + _GLIBCXX20_CONSTEXPR bool __lexicographical_compare_impl(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, @@ -969,11 +1062,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __lexicographical_compare { template + _GLIBCXX20_CONSTEXPR static bool __lc(_II1, _II1, _II2, _II2); }; template template + _GLIBCXX20_CONSTEXPR bool __lexicographical_compare<_BoolType>:: __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) @@ -987,6 +1082,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __lexicographical_compare { template + _GLIBCXX20_CONSTEXPR static bool __lc(const _Tp* __first1, const _Tp* __last1, const _Up* __first2, const _Up* __last2) @@ -994,13 +1090,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const size_t __len1 = __last1 - __first1; const size_t __len2 = __last2 - __first2; if (const size_t __len = std::min(__len1, __len2)) - if (int __result = __builtin_memcmp(__first1, __first2, __len)) + if (int __result = std::__memcmp(__first1, __first2, __len)) return __result < 0; return __len1 < __len2; } }; template + _GLIBCXX20_CONSTEXPR inline bool __lexicographical_compare_aux(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) @@ -1019,6 +1116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR _ForwardIterator __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) @@ -1057,6 +1155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @ingroup binary_search_algorithms */ template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) @@ -1112,6 +1211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * ranges are equal. */ template + _GLIBCXX20_CONSTEXPR inline bool equal(_II1 __first1, _II1 __last1, _II2 __first2) { @@ -1144,6 +1244,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * ranges are equal. */ template + _GLIBCXX20_CONSTEXPR inline bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _BinaryPredicate __binary_pred) @@ -1162,6 +1263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO #if __cplusplus >= 201103L // 4-iterator version of std::equal for use in C++11. template + _GLIBCXX20_CONSTEXPR inline bool __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { @@ -1187,6 +1289,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO // 4-iterator version of std::equal for use in C++11. template + _GLIBCXX20_CONSTEXPR inline bool __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _BinaryPredicate __binary_pred) @@ -1231,6 +1334,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * ranges are equal. */ template + _GLIBCXX20_CONSTEXPR inline bool equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { @@ -1263,6 +1367,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * ranges are equal. */ template + _GLIBCXX20_CONSTEXPR inline bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred) @@ -1294,6 +1399,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * then this is an inline call to @c memcmp. */ template + _GLIBCXX20_CONSTEXPR inline bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) @@ -1330,6 +1436,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * comp parameter instead of @c <. */ template + _GLIBCXX20_CONSTEXPR inline bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp) @@ -1347,6 +1454,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR pair<_InputIterator1, _InputIterator2> __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __binary_pred) @@ -1373,6 +1481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * to by the iterators are not equal. */ template + _GLIBCXX20_CONSTEXPR inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) @@ -1407,6 +1516,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __binary_pred) @@ -1424,6 +1534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO template + _GLIBCXX20_CONSTEXPR pair<_InputIterator1, _InputIterator2> __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -1453,6 +1564,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * to by the iterators are not equal. */ template + _GLIBCXX20_CONSTEXPR inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) @@ -1489,6 +1601,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO */ template + _GLIBCXX20_CONSTEXPR inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, diff --git a/libstdc++-v3/include/bits/stl_heap.h b/libstdc++-v3/include/bits/stl_heap.h index a711ad6..d9530e6 100644 --- a/libstdc++-v3/include/bits/stl_heap.h +++ b/libstdc++-v3/include/bits/stl_heap.h @@ -70,6 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR _Distance __is_heap_until(_RandomAccessIterator __first, _Distance __n, _Compare& __comp) @@ -88,6 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __is_heap, a predicate testing whether or not a range is a heap. // This function is an extension, not part of the C++ standard. template + _GLIBCXX20_CONSTEXPR inline bool __is_heap(_RandomAccessIterator __first, _Distance __n) { @@ -97,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template + _GLIBCXX20_CONSTEXPR inline bool __is_heap(_RandomAccessIterator __first, _Compare __comp, _Distance __n) { @@ -106,11 +109,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_CONSTEXPR inline bool __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { return std::__is_heap(__first, std::distance(__first, __last)); } template + _GLIBCXX20_CONSTEXPR inline bool __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) @@ -473,6 +478,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the range [__first, i) is a heap. */ template + _GLIBCXX20_CONSTEXPR inline _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { @@ -501,6 +507,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the range [__first, i) is a heap. Comparisons are made using __comp. */ template + _GLIBCXX20_CONSTEXPR inline _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) @@ -525,6 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @ingroup heap_algorithms */ template + _GLIBCXX20_CONSTEXPR inline bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { return std::is_heap_until(__first, __last) == __last; } @@ -538,6 +546,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @ingroup heap_algorithms */ template + _GLIBCXX20_CONSTEXPR inline bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index e9d90fa..8ab0d72 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -446,7 +446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template - auto + _GLIBCXX20_CONSTEXPR auto __niter_base(reverse_iterator<_Iterator> __it) -> decltype(__make_reverse_iterator(__niter_base(__it.base()))) { return __make_reverse_iterator(__niter_base(__it.base())); } @@ -457,7 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; template - auto + _GLIBCXX20_CONSTEXPR auto __miter_base(reverse_iterator<_Iterator> __it) -> decltype(__make_reverse_iterator(__miter_base(__it.base()))) { return __make_reverse_iterator(__miter_base(__it.base())); } diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index 230e2b0..31eff9e 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -248,16 +248,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Array comparisons. template + _GLIBCXX20_CONSTEXPR inline bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return std::equal(__one.begin(), __one.end(), __two.begin()); } template + _GLIBCXX20_CONSTEXPR inline bool operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one == __two); } template + _GLIBCXX20_CONSTEXPR inline bool operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) { @@ -266,16 +269,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template + _GLIBCXX20_CONSTEXPR inline bool operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return __two < __one; } template + _GLIBCXX20_CONSTEXPR inline bool operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one > __two); } template + _GLIBCXX20_CONSTEXPR inline bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one < __two); } @@ -289,6 +295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value >::type #else + _GLIBCXX20_CONSTEXPR void #endif swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index c687c1d..5f496f6 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -280,11 +280,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #define __cpp_lib_exchange_function 201304 +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_algorithms 201711L +#endif + /// Assign @p __new_val to @p __obj and return its previous value. template + _GLIBCXX20_CONSTEXPR inline _Tp exchange(_Tp& __obj, _Up&& __new_val) { return std::__exchange(__obj, std::forward<_Up>(__new_val)); } + #endif // Stores a tuple of indices. Used by tuple and pair, and by bind() to diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 8ebd6ba..bf15a0e 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -164,6 +164,7 @@ #endif #define __cpp_lib_list_remove_return_type 201806L #define __cpp_lib_math_constants 201907L +#define __cpp_lib_constexpr_algorithms 201711L #endif // C++2a #endif // C++17 #endif // C++14 diff --git a/libstdc++-v3/testsuite/20_util/exchange/constexpr.cc b/libstdc++-v3/testsuite/20_util/exchange/constexpr.cc new file mode 100644 index 0000000..38edfaa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/exchange/constexpr.cc @@ -0,0 +1,34 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +constexpr bool +test() +{ + constexpr double e_v = 2.71828182846; + double e = e_v; + constexpr double pi_v = 3.14159265359; + const auto x = std::exchange(e, pi_v); + + return x == e_v && e == pi_v; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/23_containers/array/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/23_containers/array/comparison_operators/constexpr.cc new file mode 100644 index 0000000..8655a9b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/array/comparison_operators/constexpr.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } +// +// 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 +// . + +#include + +constexpr std::array a1{{1, 2, 3}}; +constexpr std::array a2{{4, 5, 6}}; +constexpr std::array a3{{1, 2, 4}}; +constexpr std::array a4{{1, 3, 3}}; + +static_assert(a1 == a1); +static_assert(a1 != a2); +static_assert(a1 < a3); +static_assert(a4 > a1); +static_assert(a1 <= a3); +static_assert(a4 >= a1); diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc index f85b8ad..2ae8a5e 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc @@ -27,6 +27,6 @@ int n1 = std::get<1>(a); int n2 = std::get<1>(std::move(a)); int n3 = std::get<1>(ca); -// { dg-error "static assertion failed" "" { target *-*-* } 309 } -// { dg-error "static assertion failed" "" { target *-*-* } 318 } -// { dg-error "static assertion failed" "" { target *-*-* } 326 } +// { dg-error "static assertion failed" "" { target *-*-* } 316 } +// { dg-error "static assertion failed" "" { target *-*-* } 325 } +// { dg-error "static assertion failed" "" { target *-*-* } 333 } diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc index 0a4b1c3..5de55fc 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc @@ -22,4 +22,4 @@ typedef std::tuple_element<1, std::array>::type type; -// { dg-error "static assertion failed" "" { target *-*-* } 365 } +// { dg-error "static assertion failed" "" { target *-*-* } 372 } diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/constexpr.cc new file mode 100644 index 0000000..e62f43c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array car{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + +constexpr auto out0x = std::adjacent_find(car.begin(), car.end()); + +constexpr auto out1x = std::adjacent_find(car.begin(), car.end(), + std::equal_to()); + +constexpr bool +test() +{ + return out0x == car.begin() + 6 && out1x == car.begin() + 6; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc new file mode 100644 index 0000000..e3d187c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array cae{{0, 2, 4, 6, 8, 10}}; + +constexpr auto out2 = std::all_of(cae.begin(), cae.end(), + [](int i){ return i % 2 == 0; }); + +constexpr bool +test() +{ + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc new file mode 100644 index 0000000..0ff427c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto out3 = std::any_of(ca0.begin(), ca0.end(), + [](int i){ return i % 2 == 0; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc new file mode 100644 index 0000000..aaa4112 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto out4 = std::binary_search(ca0.begin(), ca0.end(), 5); + + const auto out5 = std::binary_search(ca0.begin(), ca0.end(), 5, + std::equal_to()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/constexpr_macro.cc b/libstdc++-v3/testsuite/25_algorithms/constexpr_macro.cc new file mode 100644 index 0000000..07808ee --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/constexpr_macro.cc @@ -0,0 +1,27 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing in " +#elif __cpp_lib_constexpr_algorithms != 201711L +# error "Feature-test macro for constexpr algorithms has wrong value in " +#endif diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc b/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc index b0366e9..826a35f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc @@ -36,6 +36,7 @@ void test01(T* result) { T t[1]; - std::copy(t, t+1, result); // { dg-error "here" } + std::copy(t, t+1, result); // { dg-error "here|deleted" } } // { dg-prune-output "not assignable" } +// { dg-prune-output "use of deleted" } diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/copy/constexpr.cc new file mode 100644 index 0000000..9a4aa25 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + + const auto out6 = std::copy(ca0.begin(), ca0.begin() + 8, ma0.begin() + 2); + + return out6 == ma0.begin() + 10; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/69478.cc b/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/69478.cc index 25e8110..293927d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/69478.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/69478.cc @@ -37,3 +37,4 @@ test01() trivial_rvalstruct a[1], b[1]; copy(std::make_move_iterator(a), std::make_move_iterator(a + 1), b); } +// { dg-prune-output "use of deleted" } diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc new file mode 100644 index 0000000..25cf97f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc @@ -0,0 +1,42 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + const auto out7 = std::copy_backward(ca0.begin(), ca0.begin() + 8, + ma0.begin() + 10); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/69478.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/69478.cc index fd7601c..84d6793 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/69478.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/69478.cc @@ -37,3 +37,4 @@ test01() trivial_rvalstruct a[1], b[1]; copy_backward(std::make_move_iterator(a), std::make_move_iterator(a+1), b); } +// { dg-prune-output "use of deleted" } diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/copy_if/constexpr.cc new file mode 100644 index 0000000..59deacf --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_if/constexpr.cc @@ -0,0 +1,42 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr bool +test() +{ + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + const auto out1 = std::copy_if(ca0.begin(), ca0.end(), ma0.begin(), + [](int i){ return i % 2 == 1; }); + + return out1 == ma0.begin() + 6; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc index 790d407..bd08be4 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc @@ -36,6 +36,7 @@ void test01(T* result) { T t[1]; - std::copy_n(t, 1, result); // { dg-error "here" } + std::copy_n(t, 1, result); // { dg-error "here|deleted" } } // { dg-prune-output "not assignable" } +// { dg-prune-output "use of deleted" } diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/constexpr.cc new file mode 100644 index 0000000..72bc1e6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr bool +test() +{ + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + std::copy_n(ca0.begin(), 12, ma0.begin()); + + return ma0[3] == ca0[3]; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc new file mode 100644 index 0000000..d7cd56d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto out8 = std::count(ca0.begin(), ca0.end(), 6); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/constexpr.cc new file mode 100644 index 0000000..2a1c7d0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr auto out9 = std::count_if(ca0.begin(), ca0.end(), + [](int i){ return i % 2 == 0; }); + +constexpr bool +test() +{ + return out9 == 6; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc new file mode 100644 index 0000000..a95704d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc @@ -0,0 +1,45 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array ca1{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + + const auto outa = std::equal(ca0.begin(), ca0.end(), ca1.begin()); + + const auto outb = std::equal(ca0.begin(), ca0.end(), cas.begin(), + [](int i, int j){ return i + 3 == j; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc new file mode 100644 index 0000000..2d57096 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array car{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + + const auto outc = std::equal_range(car.begin(), car.end(), 6); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc new file mode 100644 index 0000000..31e3568 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc @@ -0,0 +1,39 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + std::fill(ma0.begin(), ma0.end(), 66); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc new file mode 100644 index 0000000..a201191 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + + const auto outd = std::fill_n(ma0.begin(), 6, 77); + + return outd == ma0.begin() + 6; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find/constexpr.cc new file mode 100644 index 0000000..7d59de2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr auto oute = std::find(ca0.begin(), ca0.end(), 5); + +constexpr bool +test() +{ + return oute == ca0.begin() + 5; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc new file mode 100644 index 0000000..88d6cc7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc @@ -0,0 +1,47 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cam{{4, 5, 6}}; + constexpr std::array camm{{-4, -5, -6}}; + + const auto outf = std::find_end(ca0.begin(), ca0.end(), + cam.begin(), cam.end()); + + const auto outg = std::find_end(ca0.begin(), ca0.end(), + camm.begin(), camm.end(), + [](int i, int j){ return i + 1 == -j; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/constexpr.cc new file mode 100644 index 0000000..99cbed2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/constexpr.cc @@ -0,0 +1,46 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; +constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + +constexpr auto outh = std::find_first_of(ca0.begin(), ca0.end(), + cas.begin(), cas.end()); + +constexpr auto outi = std::find_first_of(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + [](int i, int j){ return i + 1 == j; }); + +constexpr bool +test() +{ + return outh == ca0.begin() + 3 && outi == ca0.begin() + 2; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc new file mode 100644 index 0000000..395a21e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto outj = std::find_if(ca0.begin(), ca0.end(), + [](int i){ return i == 6; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/constexpr.cc new file mode 100644 index 0000000..5b1b9c3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr auto outk = std::find_if_not(ca0.begin(), ca0.end(), + [](int i){ return i <= 6; }); + +constexpr bool +test() +{ + return outk == ca0.begin() + 7; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/for_each/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/for_each/constexpr.cc new file mode 100644 index 0000000..d900ef4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/for_each/constexpr.cc @@ -0,0 +1,42 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr bool +test() +{ + int tot = 0; + auto sum = [&total = tot](int i){ total += i; }; + auto sum2 = std::for_each(ca0.begin(), ca0.end(), sum); + + return tot == 66; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/generate/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/generate/constexpr.cc new file mode 100644 index 0000000..b0e26b6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + + std::generate(ma0.begin(), ma0.begin() + 6, [](){ return 42; }); + + return ma0[5] == 42; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/generate_n/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/generate_n/constexpr.cc new file mode 100644 index 0000000..f2a203e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate_n/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + + const auto outl = std::generate_n(ma0.begin(), 6, [](){ return 42; }); + + return outl == ma0.begin() + 6; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc index 3d4aee7..d3b3540 100644 --- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc @@ -23,115 +23,142 @@ namespace std { // 25.1, non-modifying sequence operations: template + _GLIBCXX20_CONSTEXPR _Funct for_each(_IIter, _IIter, _Funct); template + _GLIBCXX20_CONSTEXPR _IIter find(_IIter, _IIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _IIter find_if(_IIter, _IIter, _Predicate); #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR bool all_of(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR bool any_of(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR bool none_of(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _IIter find_if_not(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR bool is_partitioned(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _FIter partition_point(_FIter, _FIter, _Predicate); #endif template + _GLIBCXX20_CONSTEXPR _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _FIter1 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter1 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _FIter adjacent_find(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _FIter adjacent_find(_FIter, _FIter, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR typename iterator_traits<_IIter>::difference_type count(_IIter, _IIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR typename iterator_traits<_IIter>::difference_type count_if(_IIter, _IIter, _Predicate); template + _GLIBCXX20_CONSTEXPR pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2); template + _GLIBCXX20_CONSTEXPR pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR bool equal(_IIter1, _IIter1, _IIter2); template + _GLIBCXX20_CONSTEXPR bool equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2); template + _GLIBCXX20_CONSTEXPR _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _FIter search_n(_FIter, _FIter, _Size, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); // 25.2, modifying sequence operations: // 25.2.1, copy: template + _GLIBCXX20_CONSTEXPR _OIter copy(_IIter, _IIter, _OIter); template + _GLIBCXX20_CONSTEXPR _BIter2 copy_backward (_BIter1, _BIter1, _BIter2); @@ -159,90 +186,111 @@ namespace std iter_swap(_FIter1, _FIter2 b); template + _GLIBCXX20_CONSTEXPR _OIter transform(_IIter, _IIter, _OIter, _UnaryOperation op); template + _GLIBCXX20_CONSTEXPR _OIter transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); template + _GLIBCXX20_CONSTEXPR void replace(_FIter, _FIter, const _Tp&, const _Tp&); template + _GLIBCXX20_CONSTEXPR void replace_if(_FIter, _FIter, _Predicate, const _Tp&); template + _GLIBCXX20_CONSTEXPR _OIter replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); template + _GLIBCXX20_CONSTEXPR _OIter replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); template + _GLIBCXX20_CONSTEXPR void fill(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR void fill_n(_OIter, _Size n, const _Tp&); template + _GLIBCXX20_CONSTEXPR void generate(_FIter, _FIter, _Generator); template + _GLIBCXX20_CONSTEXPR void generate_n(_OIter, _Size, _Generator); template + _GLIBCXX20_CONSTEXPR _FIter remove(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter remove_if(_FIter, _FIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _OIter remove_copy(_IIter, _IIter, _OIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _OIter remove_copy_if(_IIter, _IIter, _OIter, _Predicate); #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR _OIter copy_if(_IIter, _IIter, _OIter, _Predicate); template + _GLIBCXX20_CONSTEXPR _OIter copy_n(_IIter, _Size, _OIter); template + _GLIBCXX20_CONSTEXPR pair<_OIter1, _OIter2> partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); #endif template + _GLIBCXX20_CONSTEXPR _FIter unique(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _FIter unique(_FIter, _FIter, _BinaryPredicate); template + _GLIBCXX20_CONSTEXPR _OIter unique_copy(_IIter, _IIter, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); @@ -251,6 +299,7 @@ namespace std reverse(_BIter, _BIter); template + _GLIBCXX20_CONSTEXPR _OIter reverse_copy(_BIter, _BIter, _OIter); @@ -259,6 +308,7 @@ namespace std rotate(_FIter, _FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _OIter rotate_copy (_FIter, _FIter, _FIter, _OIter); @@ -323,44 +373,54 @@ namespace std // 25.3.3, binary search: template + _GLIBCXX20_CONSTEXPR _FIter lower_bound(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter lower_bound(_FIter, _FIter, const _Tp&, _Compare); template + _GLIBCXX20_CONSTEXPR _FIter upper_bound(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR _FIter upper_bound(_FIter, _FIter, const _Tp&, _Compare); template + _GLIBCXX20_CONSTEXPR pair<_FIter, _FIter> equal_range(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR pair<_FIter, _FIter> equal_range(_FIter, _FIter, const _Tp&, _Compare); template + _GLIBCXX20_CONSTEXPR bool binary_search(_FIter, _FIter, const _Tp&); template + _GLIBCXX20_CONSTEXPR bool binary_search(_FIter, _FIter, const _Tp&, _Compare); // 25.3.4, merge: template + _GLIBCXX20_CONSTEXPR _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); @@ -374,46 +434,56 @@ namespace std // 25.3.5, set operations: template + _GLIBCXX20_CONSTEXPR bool includes(_IIter1, _IIter1, _IIter2, _IIter2); template + _GLIBCXX20_CONSTEXPR bool includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template + _GLIBCXX20_CONSTEXPR _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template + _GLIBCXX20_CONSTEXPR _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); @@ -453,34 +523,42 @@ namespace std #if __cplusplus >= 201103L template + _GLIBCXX20_CONSTEXPR bool is_heap(_RAIter, _RAIter); template + _GLIBCXX20_CONSTEXPR bool is_heap(_RAIter, _RAIter, _Compare); template + _GLIBCXX20_CONSTEXPR _RAIter is_heap_until(_RAIter, _RAIter); template + _GLIBCXX20_CONSTEXPR _RAIter is_heap_until(_RAIter, _RAIter, _Compare); template + _GLIBCXX20_CONSTEXPR bool is_sorted(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR bool is_sorted(_FIter, _FIter, _Compare); template + _GLIBCXX20_CONSTEXPR _FIter is_sorted_until(_FIter, _FIter); template + _GLIBCXX20_CONSTEXPR _FIter is_sorted_until(_FIter, _FIter, _Compare); #endif @@ -579,10 +657,12 @@ namespace std #endif template + _GLIBCXX20_CONSTEXPR bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); template + _GLIBCXX20_CONSTEXPR bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap/constexpr.cc new file mode 100644 index 0000000..5f25a30 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap/constexpr.cc @@ -0,0 +1,47 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +// heap +constexpr std::array +ah{{22, + 21, 20, + 17, 16, 19, 18, + 11, 10, 9, 8, 15, 14, 13, 12, 3, 2, 1, 0, 7, 6, 5, 4}}; + +constexpr auto outo = std::is_heap(ah.begin(), ah.end()); + +constexpr auto outp = std::is_heap(ah.begin(), ah.end(), std::less()); + +constexpr bool +test() +{ + return outo && outp; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap_until/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/constexpr.cc new file mode 100644 index 0000000..ddd4cdd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/constexpr.cc @@ -0,0 +1,48 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +// heap +constexpr std::array +ahu{{22, + 21, 20, + 17, 16, 19, 18,//v + 11, 10, 9, 8, 23, 14, 13, 12, 3, 2, 1, 0, 7, 6, 5, 4}}; + +constexpr auto outq = std::is_heap_until(ahu.begin(), ahu.end()); + +constexpr auto outr = std::is_heap_until(ahu.begin(), ahu.end(), + std::less()); + +constexpr bool +test() +{ + return outq == ahu.begin() + 11 && outr == ahu.begin() + 11; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc new file mode 100644 index 0000000..527746f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array caeo{{0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11}}; + + const auto outs = std::is_partitioned(caeo.begin(), caeo.end(), + [](int i){ return i % 2 == 0; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc new file mode 100644 index 0000000..3f5df35 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cap{{2, 1, 3, 6, 7, 5, 4, 8, 10, 9, 0, 11}}; + + const auto outt = std::is_permutation(ca0.begin(), ca0.end(), cap.begin()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/constexpr.cc new file mode 100644 index 0000000..623d72c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr auto outv = std::is_sorted(ca0.begin(), ca0.end()); + +constexpr auto outw = std::is_sorted(ca0.begin(), ca0.end(), + std::equal_to()); + +constexpr bool +test() +{ + return outv && outw; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc new file mode 100644 index 0000000..f109ee8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array aus{{0, 1, 2, 3, 4, 5, 66, 7, 8, 9, 10, 11}}; + + const auto outx = std::is_sorted_until(aus.begin(), aus.end()); + + const auto outy = std::is_sorted_until(aus.begin(), aus.end(), + std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc new file mode 100644 index 0000000..93dee5d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc @@ -0,0 +1,46 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array ca1{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto outz = !std::lexicographical_compare(ca0.begin(), ca0.end(), + ca1.begin(), ca1.end()); + + const auto outaa = !std::lexicographical_compare(ca0.begin(), ca0.end(), + ca1.begin(), ca1.end(), + std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc new file mode 100644 index 0000000..f8c191b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto outbb = std::lower_bound(ca0.begin(), ca0.end(), 6); + + const auto outcc = std::lower_bound(ca0.begin(), ca0.end(), 6, + std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc new file mode 100644 index 0000000..e240e44 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc @@ -0,0 +1,48 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + constexpr std::array camm{{-4, -5, -6}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outdd = std::merge(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), out0.begin()); + + const auto outee = std::merge(ca0.begin(), ca0.end(), + camm.begin(), camm.end(), out0.begin(), + [](int i, int j){ return i < -j; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc new file mode 100644 index 0000000..946199b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc @@ -0,0 +1,44 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cax{{0, 1, 2, 3, 4, 5, 66, 7, 8, 99, 10, 11}}; + + const auto outff = std::mismatch(ca0.begin(), ca0.end(), cax.begin()); + + const auto outgg = std::mismatch(ca0.begin(), ca0.end(), cax.begin(), + std::equal_to()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/move/69478.cc b/libstdc++-v3/testsuite/25_algorithms/move/69478.cc index ba18f00..c7f9f88 100644 --- a/libstdc++-v3/testsuite/25_algorithms/move/69478.cc +++ b/libstdc++-v3/testsuite/25_algorithms/move/69478.cc @@ -37,3 +37,4 @@ test01() trivial_rvalstruct a[1], b[1]; std::move(a, a + 1, b); } +// { dg-prune-output "use of deleted" } diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/69478.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/69478.cc index 683d7950..3a6e465 100644 --- a/libstdc++-v3/testsuite/25_algorithms/move_backward/69478.cc +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/69478.cc @@ -37,3 +37,4 @@ test01() trivial_rvalstruct a[1], b[1]; std::move_backward(a, a + 1, b); } +// { dg-prune-output "use of deleted" } diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc new file mode 100644 index 0000000..2d02ada --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto outhh = std::none_of(ca0.begin(), ca0.end(), + [](int i){ return i > 12; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc new file mode 100644 index 0000000..11c42ee --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc @@ -0,0 +1,44 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + std::array out1{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outii = std::partition_copy(ca0.begin(), ca0.end(), + out0.begin(), out1.begin(), + [](int i){ return i % 2 == 0; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_point/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/partition_point/constexpr.cc new file mode 100644 index 0000000..4ba8284 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_point/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array caeo{{0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11}}; + +constexpr bool +test() +{ + const auto outjj = std::partition_point(caeo.begin(), caeo.end(), + [](int i){ return i % 2 == 0; }); + + return outjj == caeo.begin() + 6; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove/constexpr.cc new file mode 100644 index 0000000..580ac10 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ar4{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto outkk = std::remove(ar4.begin(), ar4.end(), 7); + + return outkk == ar4.begin() + 11; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc new file mode 100644 index 0000000..a20e529 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outmm = std::remove_copy(ca0.begin(), ca0.end(), out0.begin(), 6); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc new file mode 100644 index 0000000..0758d10 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc @@ -0,0 +1,42 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outnn = std::remove_copy_if(ca0.begin(), ca0.end(), out0.begin(), + [](int i){ return i == 7; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc new file mode 100644 index 0000000..e8c0048 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ac2{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto outll = std::remove_if(ac2.begin(), ac2.end(), + [](int i){ return i == 7; }); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/constexpr.cc new file mode 100644 index 0000000..754b879 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + +constexpr bool +test() +{ + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outoo = std::replace_copy(ca0.begin(), ca0.end(), + out0.begin(), 6, 66); + + return outoo == out0.begin() + (ca0.end() - ca0.begin()); +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constexpr.cc new file mode 100644 index 0000000..1fa6bb0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; +constexpr bool +test() +{ + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outpp = std::replace_copy_if(ca0.begin(), ca0.end(), + out0.begin(), + [](int i){ return i < 6; }, 66); + + return outpp == out0.begin() + (ca0.end() - ca0.begin()); +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc new file mode 100644 index 0000000..1dc28e1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc @@ -0,0 +1,40 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ar0{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + + std::replace_if(ar0.begin(), ar0.end(), [](int i){ return i % 2 == 1; }, 42); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc new file mode 100644 index 0000000..2240109 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outqq = std::reverse_copy(ca0.rbegin(), ca0.rend(), out0.begin()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc new file mode 100644 index 0000000..63bca00 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc @@ -0,0 +1,42 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outrr = std::rotate_copy(ca0.begin(), ca0.begin() + 6, + ca0.end(), out0.begin()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc new file mode 100644 index 0000000..a611c1c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cam{{4, 5, 6}}; + + const auto outtt = std::search(ca0.begin(), ca0.end(), + cam.begin(), cam.end(), + std::equal_to()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/constexpr.cc new file mode 100644 index 0000000..ac33920 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array car{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + +constexpr auto outuu = std::search_n(car.begin(), car.end(), 2, 6); + +constexpr auto outuv = std::search_n(car.begin(), car.end(), 2, 9, + [](int i, int j){ return i == j; }); + +constexpr bool +test() +{ + return outuu == car.begin() + 6 && outuv == car.begin() + 9 ; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc new file mode 100644 index 0000000..ff913ea --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc @@ -0,0 +1,47 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outvv = std::set_difference(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), out0.begin()); + + const auto outww = std::set_difference(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin(), std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc new file mode 100644 index 0000000..f1a95a2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc @@ -0,0 +1,48 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outxx = std::set_intersection(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin()); + + const auto outyy = std::set_intersection(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin(), std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc new file mode 100644 index 0000000..ff913ea --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc @@ -0,0 +1,47 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto outvv = std::set_difference(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), out0.begin()); + + const auto outww = std::set_difference(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin(), std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc new file mode 100644 index 0000000..61d3f1e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc @@ -0,0 +1,47 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto out11 = std::set_union(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), out0.begin()); + + const auto out22 = std::set_union(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin(), std::less()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/transform/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/transform/constexpr.cc new file mode 100644 index 0000000..03c6d71 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/transform/constexpr.cc @@ -0,0 +1,47 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; +constexpr bool +test() +{ + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto out99 = std::transform(ca0.begin(), ca0.end(), out0.begin(), + [del = 6](int i){ return i + del; }); + + const auto out11 = std::transform(ca0.begin(), ca0.end(), ca0.begin(), + out0.begin(), + [](int i, int j){ return i + j; }); + + return out99 == out0.begin() + (ca0.end() - ca0.begin()) + && out11 == out0.begin() + (ca0.end() - ca0.begin()); +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/unique/constexpr.cc new file mode 100644 index 0000000..f90aaac --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ar1{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + std::array ar2{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + + const auto out33 = std::unique(ar1.begin(), ar1.end()); + + const auto out44 = std::unique(ar2.begin(), ar2.end(), std::equal_to()); + + return out33 == ar1.begin() + 10 && out44 == ar2.begin() + 10; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc new file mode 100644 index 0000000..f13f388 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc @@ -0,0 +1,44 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + std::array ar3{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}}; + std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + + const auto out55 = std::unique_copy(ar3.begin(), ar3.end(), out0.begin()); + + const auto out66 = std::unique_copy(ar3.begin(), ar3.end(), out0.begin(), + std::equal_to()); + + return true; +} + +static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc new file mode 100644 index 0000000..a0a8e25 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc @@ -0,0 +1,43 @@ +// 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include +#include + +#ifndef __cpp_lib_constexpr_algorithms +# error "Feature-test macro for constexpr algorithms missing" +#elif __cpp_lib_constexpr_algorithms < 201711L +# error "Feature-test macro for constexpr algorithms has wrong value" +#endif + +constexpr bool +test() +{ + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + + const auto out77 = std::upper_bound(ca0.begin(), ca0.end(), 6); + + const auto out88 = std::upper_bound(ca0.begin(), ca0.end(), 6, + std::less()); + + return true; +} + +static_assert(test());