Re: [libstdc++ PATCH] C++14 constexpr min/max/minmax/min_element/max_element/minmax_element, also constexpr for 20.9.5-20.9.9, aka various library functors
On 18/12/14 02:40 +0200, Ville Voutilainen wrote: Currently finishing testing on Linux-x64. The only implementation change in this patch is the initialization of the iterator variables in __minmax_element, otherwise it's just adding constexpr. Thanks, committed to trunk. commit b31a5c2c4b43d828e6c661915db29624ef96 Author: Jonathan Wakely jwak...@redhat.com Date: Thu Dec 18 21:40:57 2014 + 2014-12-22 Ville Voutilainen ville.voutilai...@gmail.com PR libstdc++/60271 C++14 constexpr min, max, minmax, min_element, max_element and minmax_element. Also constexpr for 20.9.5-20.9.9, aka various library functors. * include/bits/c++config: Add _GLIBCXX14_CONSTEXPR. * include/bits/algorithmfwd.h (min, max, minmax, min_element, max_element): Use it. * include/bits/predefined_ops.h (_Iter_less_iter, __iter_less_iter, _Iter_comp_iter, __iter_comp_iter): Likewise. * include/bits/stl_algo.h (minmax, __minmax_element, minmax_element, min, max, __min_element, min_element, __max_element, max_element) Likewise. * include/bits/stl_algobase.h (min, max): Likewise. * include/bits/stl_function.h (plus, minus, multiplies, divides, modulus, negate, equal_to, not_equal_to, greater, less, greater_equal, less_equal, logical_and, logical_or, logical_not, bit_and, bit_or, bit_xor, bit_not, unary_negate, not1, binary_negate, not2): Likewise. * testsuite/20_util/function_objects/constexpr.cc: New. * testsuite/25_algorithms/max/constexpr.cc: Likewise. * testsuite/25_algorithms/max_element/constexpr.cc: Likewise. * testsuite/25_algorithms/min/constexpr.cc: Likewise. * testsuite/25_algorithms/min_element/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax_element/constexpr.cc: Likewise. * testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error. diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index aee1eec..b45828e 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -352,10 +352,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION make_heap(_RAIter, _RAIter, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR const _Tp max(const _Tp, const _Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR const _Tp max(const _Tp, const _Tp, _Compare); @@ -363,10 +365,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // merge templatetypename _Tp +_GLIBCXX14_CONSTEXPR const _Tp min(const _Tp, const _Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR const _Tp min(const _Tp, const _Tp, _Compare); @@ -374,42 +378,52 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus = 201103L templatetypename _Tp +_GLIBCXX14_CONSTEXPR pairconst _Tp, const _Tp minmax(const _Tp, const _Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR pairconst _Tp, const _Tp minmax(const _Tp, const _Tp, _Compare); templatetypename _FIter +_GLIBCXX14_CONSTEXPR pair_FIter, _FIter minmax_element(_FIter, _FIter); templatetypename _FIter, typename _Compare +_GLIBCXX14_CONSTEXPR pair_FIter, _FIter minmax_element(_FIter, _FIter, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR _Tp min(initializer_list_Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR _Tp min(initializer_list_Tp, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR _Tp max(initializer_list_Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR _Tp max(initializer_list_Tp, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR pair_Tp, _Tp minmax(initializer_list_Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR pair_Tp, _Tp minmax(initializer_list_Tp, _Compare); #endif @@ -655,10 +669,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); templatetypename _FIter +_GLIBCXX14_CONSTEXPR _FIter max_element(_FIter, _FIter); templatetypename _FIter, typename _Compare +_GLIBCXX14_CONSTEXPR _FIter max_element(_FIter, _FIter, _Compare); @@ -672,10 +688,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); templatetypename _FIter +_GLIBCXX14_CONSTEXPR _FIter min_element(_FIter, _FIter); templatetypename _FIter, typename _Compare +_GLIBCXX14_CONSTEXPR _FIter min_element(_FIter, _FIter, _Compare); diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index ec7414d..356a526 100644 --- a/libstdc++-v3/include/bits/c++config +++
[libstdc++ PATCH] C++14 constexpr min/max/minmax/min_element/max_element/minmax_element, also constexpr for 20.9.5-20.9.9, aka various library functors
Currently finishing testing on Linux-x64. The only implementation change in this patch is the initialization of the iterator variables in __minmax_element, otherwise it's just adding constexpr. 2014-12-18 Ville Voutilainen ville.voutilai...@gmail.com C++14 constexpr min, max, minmax, min_element, max_element and minmax_element. Also constexpr for 20.9.5-20.9.9, aka various library functors. * include/bits/c++config: Add _GLIBCXX14_CONSTEXPR. * include/bits/algorithmfwd.h: Use it for min, max, minmax, min_element and max_element. * include/bits/predefined_ops.h: Use it for _Iter_less_iter and _Iter_comp_iter. * include/bits/stl_algo.h: Use it for minmax, __minmax_element, min, max, __min_element and max_element. Also initialize the iterator variables in __minmax_element. * include/bits/stl_algobase.h: Use it for min and max. * include/bits/stl_function.h: Use it for plus, minus, multiplies, divides, modulus, negate, equal_to, not_equal_to, greater, less, greater_equal, less_equal, logical_and, logical_or, logical_not, bit_and, bit_or, bit_xor, bit_not, unary_negate, not1, binary_negate and not2. * testsuite/20_util/function_objects/constexpr.cc: New. * testsuite/25_algorithms/max/constexpr.cc: Likewise. * testsuite/25_algorithms/max_element/constexpr.cc: Likewise. * testsuite/25_algorithms/min/constexpr.cc: Likewise. * testsuite/25_algorithms/min_element/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax_element/constexpr.cc: Likewise. diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index aee1eec..b45828e 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -352,10 +352,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION make_heap(_RAIter, _RAIter, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR const _Tp max(const _Tp, const _Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR const _Tp max(const _Tp, const _Tp, _Compare); @@ -363,10 +365,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // merge templatetypename _Tp +_GLIBCXX14_CONSTEXPR const _Tp min(const _Tp, const _Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR const _Tp min(const _Tp, const _Tp, _Compare); @@ -374,42 +378,52 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus = 201103L templatetypename _Tp +_GLIBCXX14_CONSTEXPR pairconst _Tp, const _Tp minmax(const _Tp, const _Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR pairconst _Tp, const _Tp minmax(const _Tp, const _Tp, _Compare); templatetypename _FIter +_GLIBCXX14_CONSTEXPR pair_FIter, _FIter minmax_element(_FIter, _FIter); templatetypename _FIter, typename _Compare +_GLIBCXX14_CONSTEXPR pair_FIter, _FIter minmax_element(_FIter, _FIter, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR _Tp min(initializer_list_Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR _Tp min(initializer_list_Tp, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR _Tp max(initializer_list_Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR _Tp max(initializer_list_Tp, _Compare); templatetypename _Tp +_GLIBCXX14_CONSTEXPR pair_Tp, _Tp minmax(initializer_list_Tp); templatetypename _Tp, typename _Compare +_GLIBCXX14_CONSTEXPR pair_Tp, _Tp minmax(initializer_list_Tp, _Compare); #endif @@ -655,10 +669,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); templatetypename _FIter +_GLIBCXX14_CONSTEXPR _FIter max_element(_FIter, _FIter); templatetypename _FIter, typename _Compare +_GLIBCXX14_CONSTEXPR _FIter max_element(_FIter, _FIter, _Compare); @@ -672,10 +688,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); templatetypename _FIter +_GLIBCXX14_CONSTEXPR _FIter min_element(_FIter, _FIter); templatetypename _FIter, typename _Compare +_GLIBCXX14_CONSTEXPR _FIter min_element(_FIter, _FIter, _Compare); diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 337f1e5..5fbc7c3 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -103,6 +103,14 @@ # endif #endif +#ifndef _GLIBCXX14_CONSTEXPR +# if __cplusplus = 201402L +# define _GLIBCXX14_CONSTEXPR constexpr +# else +# define _GLIBCXX14_CONSTEXPR +# endif +#endif + // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus = 201103L diff --git
Re: [libstdc++ PATCH] C++14 constexpr min/max/minmax/min_element/max_element/minmax_element, also constexpr for 20.9.5-20.9.9, aka various library functors
On 18 December 2014 at 02:16, Ville Voutilainen ville.voutilai...@gmail.com wrote: Currently finishing testing on Linux-x64. The only implementation change in this patch is the initialization of the iterator variables in __minmax_element, otherwise it's just adding constexpr. 2014-12-18 Ville Voutilainen ville.voutilai...@gmail.com C++14 constexpr min, max, minmax, min_element, max_element and minmax_element. Also constexpr for 20.9.5-20.9.9, aka various library functors. * include/bits/c++config: Add _GLIBCXX14_CONSTEXPR. * include/bits/algorithmfwd.h: Use it for min, max, minmax, min_element and max_element. * include/bits/predefined_ops.h: Use it for _Iter_less_iter and _Iter_comp_iter. * include/bits/stl_algo.h: Use it for minmax, __minmax_element, min, max, __min_element and max_element. Also initialize the iterator variables in __minmax_element. * include/bits/stl_algobase.h: Use it for min and max. * include/bits/stl_function.h: Use it for plus, minus, multiplies, divides, modulus, negate, equal_to, not_equal_to, greater, less, greater_equal, less_equal, logical_and, logical_or, logical_not, bit_and, bit_or, bit_xor, bit_not, unary_negate, not1, binary_negate and not2. * testsuite/20_util/function_objects/constexpr.cc: New. * testsuite/25_algorithms/max/constexpr.cc: Likewise. * testsuite/25_algorithms/max_element/constexpr.cc: Likewise. * testsuite/25_algorithms/min/constexpr.cc: Likewise. * testsuite/25_algorithms/min_element/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax_element/constexpr.cc: Likewise. Oh well, slight goofs in the changelog for std_algo.h. Let's try that one more time. 2014-12-18 Ville Voutilainen ville.voutilai...@gmail.com C++14 constexpr min, max, minmax, min_element, max_element and minmax_element. Also constexpr for 20.9.5-20.9.9, aka various library functors. * include/bits/c++config: Add _GLIBCXX14_CONSTEXPR. * include/bits/algorithmfwd.h: Use it for min, max, minmax, min_element and max_element. * include/bits/predefined_ops.h: Use it for _Iter_less_iter and _Iter_comp_iter. * include/bits/stl_algo.h: Use it for minmax, __minmax_element, minmax_element, min, max, __min_element, min_element, __max_element and max_element. Also initialize the iterator variables in __minmax_element. * include/bits/stl_algobase.h: Use it for min and max. * include/bits/stl_function.h: Use it for plus, minus, multiplies, divides, modulus, negate, equal_to, not_equal_to, greater, less, greater_equal, less_equal, logical_and, logical_or, logical_not, bit_and, bit_or, bit_xor, bit_not, unary_negate, not1, binary_negate and not2. * testsuite/20_util/function_objects/constexpr.cc: New. * testsuite/25_algorithms/max/constexpr.cc: Likewise. * testsuite/25_algorithms/max_element/constexpr.cc: Likewise. * testsuite/25_algorithms/min/constexpr.cc: Likewise. * testsuite/25_algorithms/min_element/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax/constexpr.cc: Likewise. * testsuite/25_algorithms/minmax_element/constexpr.cc: Likewise.