------------------------------------------------- -----------------
``__cpp_lib_constexpr_misc`` *unimplemented*
------------------------------------------------- -----------------
+ ``__cpp_lib_constexpr_numeric`` ``201911L``
+ ------------------------------------------------- -----------------
``__cpp_lib_constexpr_swap_algorithms`` *unimplemented*
------------------------------------------------- -----------------
``__cpp_lib_constexpr_utility`` ``201811L``
{
template <class InputIterator, class T>
- T
+ constexpr T // constexpr since C++20
accumulate(InputIterator first, InputIterator last, T init);
template <class InputIterator, class T, class BinaryOperation>
- T
+ constexpr T // constexpr since C++20
accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
template<class InputIterator>
- typename iterator_traits<InputIterator>::value_type
+ constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20
reduce(InputIterator first, InputIterator last); // C++17
template<class InputIterator, class T>
- T
+ constexpr T // constexpr since C++20
reduce(InputIterator first, InputIterator last, T init); // C++17
template<class InputIterator, class T, class BinaryOperation>
- T
+ constexpr T // constexpr since C++20
reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17
template <class InputIterator1, class InputIterator2, class T>
- T
+ constexpr T // constexpr since C++20
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
- T
+ constexpr T // constexpr since C++20
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
template<class InputIterator1, class InputIterator2, class T>
- T
+ constexpr T // constexpr since C++20
transform_reduce(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init); // C++17
template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
- T
+ constexpr T // constexpr since C++20
transform_reduce(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init,
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17
template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>
- T
+ constexpr T // constexpr since C++20
transform_reduce(InputIterator first, InputIterator last, T init,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template <class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
partial_sum(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
template<class InputIterator, class OutputIterator, class T>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init); // C++17
template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init, BinaryOperation binary_op); // C++17
template<class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
template<class InputIterator, class OutputIterator, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op); // C++17
template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op, T init); // C++17
template<class InputIterator, class OutputIterator, class T,
class BinaryOperation, class UnaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
transform_exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template<class InputIterator, class OutputIterator,
class BinaryOperation, class UnaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
transform_inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template<class InputIterator, class OutputIterator,
class BinaryOperation, class UnaryOperation, class T>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
transform_inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result,
BinaryOperation binary_op, UnaryOperation unary_op,
T init); // C++17
template <class InputIterator, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryOperation>
- OutputIterator
+ constexpr OutputIterator // constexpr since C++20
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
template <class ForwardIterator, class T>
- void iota(ForwardIterator first, ForwardIterator last, T value);
+ constexpr void // constexpr since C++20
+ iota(ForwardIterator first, ForwardIterator last, T value);
template <class M, class N>
constexpr common_type_t<M,N> gcd(M m, N n); // C++17
template <class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n); // C++17
-integer midpoint(integer a, integer b); // C++20
-pointer midpoint(pointer a, pointer b); // C++20
-floating_point midpoint(floating_point a, floating_point b); // C++20
+template<class T>
+ constexpr T midpoint(T a, T b) noexcept; // C++20
+
+template<class T>
+ constexpr T* midpoint(T* a, T* b); // C++20
} // std
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
}
template <class _InputIterator, class _Tp, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
{
#if _LIBCPP_STD_VER > 14
template <class _InputIterator, class _Tp, class _BinaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)
{
}
template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
{
}
template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename iterator_traits<_InputIterator>::value_type
reduce(_InputIterator __first, _InputIterator __last)
{
#endif
template <class _InputIterator1, class _InputIterator2, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
{
}
template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
_Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
#if _LIBCPP_STD_VER > 14
template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
transform_reduce(_InputIterator __first, _InputIterator __last,
_Tp __init, _BinaryOp __b, _UnaryOp __u)
template <class _InputIterator1, class _InputIterator2,
class _Tp, class _BinaryOp1, class _BinaryOp2>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2)
}
template <class _InputIterator1, class _InputIterator2, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Tp
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init)
#endif
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
#if _LIBCPP_STD_VER > 14
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init, _BinaryOp __b)
}
template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init)
}
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _Tp __init)
{
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b)
{
}
template <class _InputIterator, class _OutputIterator>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result)
{
template <class _InputIterator, class _OutputIterator, class _Tp,
class _BinaryOp, class _UnaryOp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init,
}
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
-_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
{
for (; __first != __last; ++__first, (void) ++__result) {
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
-_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
{
if (__first != __last) {
#endif
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
{
__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_misc 201811L <array> <functional> <iterator>
<string_view> <tuple> <utility>
+__cpp_lib_constexpr_numeric 201911L <numeric>
__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>
__cpp_lib_constexpr_utility 201811L <utility>
__cpp_lib_destroying_delete 201806L <new>
// # define __cpp_lib_concepts 201806L
# define __cpp_lib_constexpr_dynamic_alloc 201907L
// # define __cpp_lib_constexpr_misc 201811L
+# define __cpp_lib_constexpr_numeric 201911L
// # define __cpp_lib_constexpr_swap_algorithms 201806L
# define __cpp_lib_constexpr_utility 201811L
# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
// Test the feature test macros defined by <numeric>
/* Constant Value
+ __cpp_lib_constexpr_numeric 201911L [C++2a]
__cpp_lib_gcd_lcm 201606L [C++17]
__cpp_lib_interpolate 201902L [C++2a]
__cpp_lib_parallel_algorithm 201603L [C++17]
#if TEST_STD_VER < 14
+# ifdef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
+# endif
+
# ifdef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should not be defined before c++17"
# endif
#elif TEST_STD_VER == 14
+# ifdef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
+# endif
+
# ifdef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should not be defined before c++17"
# endif
#elif TEST_STD_VER == 17
+# ifdef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
+# endif
+
# ifndef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should be defined in c++17"
# endif
#elif TEST_STD_VER > 17
+# ifndef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should be defined in c++2a"
+# endif
+# if __cpp_lib_constexpr_numeric != 201911L
+# error "__cpp_lib_constexpr_numeric should have the value 201911L in c++2a"
+# endif
+
# ifndef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should be defined in c++2a"
# endif
__cpp_lib_concepts 201806L [C++2a]
__cpp_lib_constexpr_dynamic_alloc 201907L [C++2a]
__cpp_lib_constexpr_misc 201811L [C++2a]
+ __cpp_lib_constexpr_numeric 201911L [C++2a]
__cpp_lib_constexpr_swap_algorithms 201806L [C++2a]
__cpp_lib_constexpr_utility 201811L [C++2a]
__cpp_lib_destroying_delete 201806L [C++2a]
# error "__cpp_lib_constexpr_misc should not be defined before c++2a"
# endif
+# ifdef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
+# endif
+
# ifdef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should not be defined before c++2a"
# endif
# error "__cpp_lib_constexpr_misc should not be defined before c++2a"
# endif
+# ifdef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
+# endif
+
# ifdef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should not be defined before c++2a"
# endif
# error "__cpp_lib_constexpr_misc should not be defined before c++2a"
# endif
+# ifdef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
+# endif
+
# ifdef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should not be defined before c++2a"
# endif
# endif
# endif
+# ifndef __cpp_lib_constexpr_numeric
+# error "__cpp_lib_constexpr_numeric should be defined in c++2a"
+# endif
+# if __cpp_lib_constexpr_numeric != 201911L
+# error "__cpp_lib_constexpr_numeric should have the value 201911L in c++2a"
+# endif
+
# if !defined(_LIBCPP_VERSION)
# ifndef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should be defined in c++2a"
// <numeric>
+// Became constexpr in C++20
// template <InputIterator Iter, MoveConstructible T>
// requires HasPlus<T, Iter::reference>
// && HasAssign<T, HasPlus<T, Iter::reference>::result_type>
#include "test_iterators.h"
template <class Iter, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter first, Iter last, T init, T x)
{
assert(std::accumulate(first, last, init) == x);
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
test(Iter(ia), Iter(ia+sa), 10, 31);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*> >();
test<forward_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <InputIterator Iter, MoveConstructible T,
// Callable<auto, const T&, Iter::reference> BinaryOperation>
// requires HasAssign<T, BinaryOperation::result_type>
#include "test_iterators.h"
template <class Iter, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter first, Iter last, T init, T x)
{
assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
test(Iter(ia), Iter(ia+sa), 10, 7200);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*> >();
test<forward_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <InputIterator InIter,
// OutputIterator<auto, const InIter::value_type&> OutIter>
// requires HasMinus<InIter::value_type, InIter::value_type>
#include "test_iterators.h"
template <class InIter, class OutIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {15, 10, 6, 3, 1};
{
int i_;
- X& operator=(const X&);
+ TEST_CONSTEXPR_CXX20 X& operator=(const X&);
public:
- explicit X(int i) : i_(i) {}
- X(const X& x) : i_(x.i_) {}
- X& operator=(X&& x)
+ TEST_CONSTEXPR_CXX20 explicit X(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX20 X(const X& x) : i_(x.i_) {}
+ TEST_CONSTEXPR_CXX20 X& operator=(X&& x)
{
i_ = x.i_;
x.i_ = -1;
return *this;
}
- friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+ TEST_CONSTEXPR_CXX20 friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
friend class Y;
};
{
int i_;
- Y& operator=(const Y&);
+ TEST_CONSTEXPR_CXX20 Y& operator=(const Y&);
public:
- explicit Y(int i) : i_(i) {}
- Y(const Y& y) : i_(y.i_) {}
- void operator=(const X& x) {i_ = x.i_;}
+ TEST_CONSTEXPR_CXX20 explicit Y(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX20 Y(const Y& y) : i_(y.i_) {}
+ TEST_CONSTEXPR_CXX20 void operator=(const X& x) {i_ = x.i_;}
};
#endif
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*>, output_iterator<int*> >();
test<input_iterator<const int*>, forward_iterator<int*> >();
std::adjacent_difference(x, x+3, y);
#endif
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <InputIterator InIter,
// OutputIterator<auto, const InIter::value_type&> OutIter,
// Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation>
#include "test_iterators.h"
template <class InIter, class OutIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {15, 10, 6, 3, 1};
{
int i_;
- X& operator=(const X&);
+ TEST_CONSTEXPR_CXX20 X& operator=(const X&);
public:
- explicit X(int i) : i_(i) {}
- X(const X& x) : i_(x.i_) {}
- X& operator=(X&& x)
+ TEST_CONSTEXPR_CXX20 explicit X(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX20 X(const X& x) : i_(x.i_) {}
+ TEST_CONSTEXPR_CXX20 X& operator=(X&& x)
{
i_ = x.i_;
x.i_ = -1;
return *this;
}
- friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+ TEST_CONSTEXPR_CXX20 friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
friend class Y;
};
{
int i_;
- Y& operator=(const Y&);
+ TEST_CONSTEXPR_CXX20 Y& operator=(const Y&);
public:
- explicit Y(int i) : i_(i) {}
- Y(const Y& y) : i_(y.i_) {}
- void operator=(const X& x) {i_ = x.i_;}
+ TEST_CONSTEXPR_CXX20 explicit Y(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX20 Y(const Y& y) : i_(y.i_) {}
+ TEST_CONSTEXPR_CXX20 void operator=(const X& x) {i_ = x.i_;}
};
#endif
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*>, output_iterator<int*> >();
test<input_iterator<const int*>, forward_iterator<int*> >();
std::adjacent_difference(x, x+3, y, std::minus<X>());
#endif
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T>
// OutputIterator exclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result, T init);
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
template <class Iter1, class T, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
// Not in place
- std::exclusive_scan(first, last, std::back_inserter(v), init);
+ std::exclusive_scan(first, last, v.begin(), init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::exclusive_scan(v.begin(), v.end(), v.begin(), init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
-
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 3, 5, 7, 9};
test(Iter(ia), Iter(ia + i), 0, pRes, pRes + i);
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::exclusive_scan(v.begin(), v.end(), v.begin(), size_t{50});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::exclusive_scan(v.begin(), v.end(), v.begin(), size_t{30});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::exclusive_scan(v.begin(), v.end(), v.begin(), size_t{40});
for (size_t i = 0; i < v.size(); ++i)
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
basic_tests();
test<const int*>();
test< int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
// OutputIterator
// exclusive_scan(InputIterator first, InputIterator last,
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
template <class Iter1, class T, class Op, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, T init, Op op, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
// Not in place
- std::exclusive_scan(first, last, std::back_inserter(v), init, op);
+ std::exclusive_scan(first, last, v.begin(), init, op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::exclusive_scan(v.begin(), v.end(), v.begin(), init, op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 3, 5, 7, 9};
}
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
// All the iterator categories
test<input_iterator <const int*> >();
// Make sure that the calculations are done using the init typedef
{
- std::vector<unsigned char> v(10);
+ std::array<unsigned char, 10> v;
std::iota(v.begin(), v.end(), static_cast<unsigned char>(1));
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> res;
std::exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>());
+#else
+ std::array<size_t, 10> res;
+ std::exclusive_scan(v.begin(), v.end(), res.begin(), 1, std::multiplies<>());
+#endif
assert(res.size() == 10);
size_t j = 1;
}
}
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T>
// OutputIterator inclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result, T init);
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
template <class Iter1, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
// Not in place
- std::inclusive_scan(first, last, std::back_inserter(v));
+ std::inclusive_scan(first, last, v.begin());
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::inclusive_scan(v.begin(), v.end(), v.begin());
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 3, 5, 7, 9};
test(Iter(ia), Iter(ia + i), pRes, pRes + i);
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::inclusive_scan(v.begin(), v.end(), v.begin());
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::inclusive_scan(v.begin(), v.end(), v.begin());
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::inclusive_scan(v.begin(), v.end(), v.begin());
for (size_t i = 0; i < v.size(); ++i)
}
{
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> v, res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res));
+#else
+ std::array<size_t, 0> v, res;
+ std::inclusive_scan(v.begin(), v.end(), res.begin());
+#endif
assert(res.empty());
}
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
basic_tests();
test<const int*>();
test< int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
// OutputIterator
// inclusive_scan(InputIterator first, InputIterator last,
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
-template <class Iter1, class T, class Op, class Iter2>
-void
+template <class Iter1, class Op, class Iter2>
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, Op op, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
// Not in place
- std::inclusive_scan(first, last, std::back_inserter(v), op);
+ std::inclusive_scan(first, last, v.begin(), op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::inclusive_scan(v.begin(), v.end(), v.begin(), op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 3, 5, 7, 9};
}
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>());
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>());
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>());
for (size_t i = 0; i < v.size(); ++i)
}
{
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> v, res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>());
+#else
+ std::array<size_t, 0> v, res;
+ std::inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>());
+#endif
assert(res.empty());
}
}
-
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
-
basic_tests();
// All the iterator categories
-// test<input_iterator <const int*> >();
-// test<forward_iterator <const int*> >();
-// test<bidirectional_iterator<const int*> >();
-// test<random_access_iterator<const int*> >();
-// test<const int*>();
-// test< int*>();
-
+ test<input_iterator <const int*> >();
+ test<forward_iterator <const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+ test< int*>();
+
+ return true;
+}
- return 0;
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
// OutputIterator
// inclusive_scan(InputIterator first, InputIterator last,
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
template <class Iter1, class T, class Op, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, Op op, T init, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
// Not in place
- std::inclusive_scan(first, last, std::back_inserter(v), op, init);
+ std::inclusive_scan(first, last, v.begin(), op, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::inclusive_scan(v.begin(), v.end(), v.begin(), op, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 3, 5, 7, 9};
}
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), size_t{50});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), size_t{40});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), size_t{30});
for (size_t i = 0; i < v.size(); ++i)
}
{
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> v, res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), size_t{40});
+#else
+ std::array<size_t, 0> v, res;
+ std::inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>(), size_t{40});
+#endif
assert(res.empty());
}
// Make sure that the calculations are done using the init typedef
{
- std::vector<unsigned char> v(10);
+ std::array<unsigned char, 10> v;
std::iota(v.begin(), v.end(), static_cast<unsigned char>(1));
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), size_t{1});
+#else
+ std::array<size_t, 10> res;
+ std::inclusive_scan(v.begin(), v.end(), res.begin(), std::multiplies<>(), size_t{1});
+#endif
assert(res.size() == 10);
size_t j = 1;
}
}
-
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
-
basic_tests();
// All the iterator categories
test<const int*>();
test< int*>();
+ return true;
+}
- return 0;
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T>
// requires HasMultiply<Iter1::reference, Iter2::reference>
// && HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type>
#include "test_iterators.h"
template <class Iter1, class Iter2, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
{
assert(std::inner_product(first1, last1, first2, init) == x);
}
template <class Iter1, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int a[] = {1, 2, 3, 4, 5, 6};
test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 66);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*>, input_iterator<const int*> >();
test<input_iterator<const int*>, forward_iterator<const int*> >();
test<const int*, random_access_iterator<const int*> >();
test<const int*, const int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T,
// class BinaryOperation1,
// Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
#include "test_iterators.h"
template <class Iter1, class Iter2, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
{
assert(std::inner_product(first1, last1, first2, init,
}
template <class Iter1, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int a[] = {1, 2, 3, 4, 5, 6};
test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 1176490);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*>, input_iterator<const int*> >();
test<input_iterator<const int*>, forward_iterator<const int*> >();
test<const int*, random_access_iterator<const int*> >();
test<const int*, const int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <class ForwardIterator, class T>
// void iota(ForwardIterator first, ForwardIterator last, T value);
#include "test_iterators.h"
template <class InIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5};
assert(ia[i] == ir[i]);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<forward_iterator<int*> >();
test<bidirectional_iterator<int*> >();
test<random_access_iterator<int*> >();
test<int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template <InputIterator InIter, OutputIterator<auto, const InIter::value_type&> OutIter>
// requires HasPlus<InIter::value_type, InIter::reference>
// && HasAssign<InIter::value_type,
#include "test_iterators.h"
template <class InIter, class OutIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5};
assert(ib[i] == ir[i]);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*>, output_iterator<int*> >();
test<input_iterator<const int*>, forward_iterator<int*> >();
test<const int*, random_access_iterator<int*> >();
test<const int*, int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
+// Became constexpr in C++20
// template<InputIterator InIter,
// OutputIterator<auto, const InIter::value_type&> OutIter,
// Callable<auto, const InIter::value_type&, InIter::reference> BinaryOperation>
#include "test_iterators.h"
template <class InIter, class OutIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5};
assert(ib[i] == ir[i]);
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test<input_iterator<const int*>, output_iterator<int*> >();
test<input_iterator<const int*>, forward_iterator<int*> >();
test<const int*, random_access_iterator<int*> >();
test<const int*, int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator>
// typename iterator_traits<InputIterator>::value_type
// reduce(InputIterator first, InputIterator last);
#include "test_iterators.h"
template <class Iter, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter first, Iter last, T x)
{
static_assert( std::is_same_v<typename std::iterator_traits<decltype(first)>::value_type,
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
}
template <typename T>
-void test_return_type()
+TEST_CONSTEXPR_CXX20 void
+test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<T, decltype(std::reduce(p, p))> );
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test_return_type<char>();
test_return_type<int>();
test<random_access_iterator<const int*> >();
test<const int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class T>
// T reduce(InputIterator first, InputIterator last, T init);
#include "test_iterators.h"
template <class Iter, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter first, Iter last, T init, T x)
{
static_assert( std::is_same_v<T, decltype(std::reduce(first, last, init))> );
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
}
template <typename T, typename Init>
-void test_return_type()
+TEST_CONSTEXPR_CXX20 void
+test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init, decltype(std::reduce(p, p, Init{}))> );
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test_return_type<char, int>();
test_return_type<int, int>();
test<random_access_iterator<const int*> >();
test<const int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class T, class BinaryOperation>
// T reduce(InputIterator first, InputIterator last, T init, BinaryOperation op);
#include "test_iterators.h"
template <class Iter, class T, class Op>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter first, Iter last, T init, Op op, T x)
{
static_assert( std::is_same_v<T, decltype(std::reduce(first, last, init, op))>, "" );
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
}
template <typename T, typename Init>
-void test_return_type()
+TEST_CONSTEXPR_CXX20 void
+test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init, decltype(std::reduce(p, p, Init{}, std::plus<>()))>, "" );
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test_return_type<char, int>();
test_return_type<int, int>();
assert(res == 40320); // 8! will not fit into a char
}
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
struct add_one {
template <typename T>
};
template <class Iter1, class BOp, class UOp, class T, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
+
// Test not in-place
- std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop);
+ std::transform_exclusive_scan(first, last, v.begin(), init, bop, uop);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// Test in-place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = { 1, 3, 5, 7, 9 };
}
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), size_t{50}, std::plus<>(), add_one{});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), size_t{30}, std::plus<>(), add_one{});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), size_t{40}, std::plus<>(), add_one{});
for (size_t i = 0; i < v.size(); ++i)
}
{
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> v, res;
std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), size_t{40}, std::plus<>(), add_one{});
+#else
+ std::array<size_t, 0> v, res;
+ std::transform_exclusive_scan(v.begin(), v.end(), res.begin(), size_t{40}, std::plus<>(), add_one{});
+#endif
assert(res.empty());
}
// Make sure that the calculations are done using the init typedef
{
- std::vector<unsigned char> v(10);
+ std::array<unsigned char, 10> v;
std::iota(v.begin(), v.end(), static_cast<unsigned char>(1));
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> res;
std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), size_t{1}, std::multiplies<>(), add_one{});
+#else
+ std::array<size_t, 10> res;
+ std::transform_exclusive_scan(v.begin(), v.end(), res.begin(), size_t{1}, std::multiplies<>(), add_one{});
+#endif
assert(res.size() == 10);
size_t j = 1;
}
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
basic_tests();
test<const int*>();
test< int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
struct add_one {
template <typename T>
};
template <class Iter1, class BOp, class UOp, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, BOp bop, UOp uop, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
+
// Test not in-place
- std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop);
+ std::transform_inclusive_scan(first, last, v.begin(), bop, uop);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// Test in-place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = { 1, 3, 5, 7, 9 };
}
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{});
for (size_t i = 0; i < v.size(); ++i)
}
{
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> v, res;
std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), add_one{});
+#else
+ std::array<size_t, 0> v, res;
+ std::transform_inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>(), add_one{});
+#endif
assert(res.empty());
}
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
basic_tests();
test<const int*>();
test< int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
#include <numeric>
#include <algorithm>
+#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include "test_macros.h"
#include "test_iterators.h"
+// FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER > 17
+#include <span>
+#endif
struct add_one {
template <typename T>
};
template <class Iter1, class BOp, class UOp, class T, class Iter2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
{
- std::vector<typename std::iterator_traits<Iter1>::value_type> v;
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+ size_t size = std::distance(first, last);
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
+
+ std::vector<typename std::iterator_traits<Iter1>::value_type> v(size);
+#else
+ assert((size <= 5) && "Increment the size of the array");
+ typename std::iterator_traits<Iter1>::value_type b[5];
+ std::span<typename std::iterator_traits<Iter1>::value_type> v{b, size};
+#endif
+
// Test not in-place
- std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop, init);
+ std::transform_inclusive_scan(first, last, v.begin(), bop, uop, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// Test in-place
- v.clear();
- v.assign(first, last);
+ std::copy(first, last, v.begin());
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = { 1, 3, 5, 7, 9 };
}
}
-size_t triangle(size_t n) { return n*(n+1)/2; }
+constexpr size_t triangle(size_t n) { return n*(n+1)/2; }
// Basic sanity
-void basic_tests()
+TEST_CONSTEXPR_CXX20 void
+basic_tests()
{
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::fill(v.begin(), v.end(), 3);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{}, size_t{50});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 0);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{}, size_t{30});
for (size_t i = 0; i < v.size(); ++i)
}
{
- std::vector<size_t> v(10);
+ std::array<size_t, 10> v;
std::iota(v.begin(), v.end(), 1);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{}, size_t{40});
for (size_t i = 0; i < v.size(); ++i)
}
{
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> v, res;
std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), add_one{}, size_t{1});
+#else
+ std::array<size_t, 0> v, res;
+ std::transform_inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>(), add_one{}, size_t{1});
+#endif
assert(res.empty());
}
// Make sure that the calculations are done using the init typedef
{
- std::vector<unsigned char> v(10);
+ std::array<unsigned char, 10> v;
std::iota(v.begin(), v.end(), static_cast<unsigned char>(1));
+ // C++17 doesn't test constexpr so can use a vector.
+ // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC
+ // don't have the support yet. In these cases use a std::span for the test.
+ // FIXME Remove constexpr vector workaround introduced in D90569
+#if TEST_STD_VER < 20 || \
+ (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L)
std::vector<size_t> res;
std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), add_one{}, size_t{1});
+#else
+ std::array<size_t, 10> res;
+ std::transform_inclusive_scan(v.begin(), v.end(), res.begin(), std::multiplies<>(), add_one{}, size_t{1});
+#endif
assert(res.size() == 10);
size_t j = 2;
}
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
basic_tests();
test<const int*>();
test< int*>();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template <class InputIterator1, class T,
// class BinaryOperation, class UnaryOperation>
// T transform_reduce(InputIterator1 first1, InputIterator1 last1,
};
template <class Iter1, class T, class BOp, class UOp>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first1, Iter1 last1, T init, BOp bOp, UOp uOp, T x)
{
static_assert( std::is_same_v<T,
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
}
template <typename T, typename Init>
-void test_return_type()
+TEST_CONSTEXPR_CXX20 void
+test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init,
decltype(std::transform_reduce(p, p, Init{}, std::plus<>(), identity()))> );
}
-void test_move_only_types()
+TEST_CONSTEXPR_CXX20 void
+test_move_only_types()
{
MoveOnly ia[] = {{1}, {2}, {3}};
assert(60 ==
[](const MoveOnly& target) { return MoveOnly{target.get() * 10}; }).get());
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test_return_type<char, int>();
test_return_type<int, int>();
test_move_only_types();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template <class InputIterator1, class InputIterator2, class T>
// T transform_reduce(InputIterator1 first1, InputIterator1 last1,
// InputIterator2 first2, T init);
#include "test_iterators.h"
template <class Iter1, class Iter2, class T>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
{
static_assert( std::is_same_v<T,
}
template <class SIter, class UIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
}
template <typename T, typename Init>
-void test_return_type()
+TEST_CONSTEXPR_CXX20 void
+test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init,
decltype(std::transform_reduce(p, p, p, Init{}))> );
}
-void test_move_only_types()
+TEST_CONSTEXPR_CXX20 void
+test_move_only_types()
{
MoveOnly ia[] = {{1}, {2}, {3}};
MoveOnly ib[] = {{1}, {2}, {3}};
std::transform_reduce(std::begin(ia), std::end(ia), std::begin(ib), MoveOnly{0}).get());
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test_return_type<char, int>();
test_return_type<int, int>();
test_move_only_types();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
// <numeric>
// UNSUPPORTED: c++03, c++11, c++14
+// Became constexpr in C++20
// template <class InputIterator1, class InputIterator2, class T,
// class BinaryOperation1, class BinaryOperation2>
// T transform_reduce(InputIterator1 first1, InputIterator1 last1,
#include "test_iterators.h"
template <class Iter1, class Iter2, class T, class Op1, class Op2>
-void
+TEST_CONSTEXPR_CXX20 void
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, Op1 op1, Op2 op2, T x)
{
static_assert( std::is_same_v<T,
}
template <class SIter, class UIter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
}
template <typename T, typename Init>
-void test_return_type()
+TEST_CONSTEXPR_CXX20 void
+test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init,
decltype(std::transform_reduce(p, p, p, Init{}, std::plus<>(), std::multiplies<>()))> );
}
-void test_move_only_types()
+TEST_CONSTEXPR_CXX20 void
+test_move_only_types()
{
MoveOnly ia[] = {{1}, {2}, {3}};
MoveOnly ib[] = {{1}, {2}, {3}};
[](const MoveOnly& lhs, const MoveOnly& rhs) { return MoveOnly{lhs.get() * rhs.get()}; }).get());
}
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool
+test()
{
test_return_type<char, int>();
test_return_type<int, int>();
test_move_only_types();
- return 0;
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ static_assert(test());
+#endif
+ return 0;
}
"headers": ["array", "functional", "iterator", "string_view", "tuple", "utility"],
"unimplemented": True,
}, {
+ "name": "__cpp_lib_constexpr_numeric",
+ "values": { "c++2a": int(201911) },
+ "headers": ["numeric"],
+ }, {
"name": "__cpp_lib_bind_front",
"values": { "c++2a": int(201811) },
"headers": ["functional"],
<tr><td><a href="https://wg21.link/P1394">P1394</a></td><td>LWG</td><td>Range constructor for std::span </td><td>Belfast</td><td><i> </i></td><td></td></tr>
<tr><td><a href="https://wg21.link/P1456">P1456</a></td><td>LWG</td><td>Move-only views </td><td>Belfast</td><td><i> </i></td><td></td></tr>
<tr><td><a href="https://wg21.link/P1622">P1622</a></td><td>LWG</td><td>Mandating the Standard Library: Clause 32 - Thread support library </td><td>Belfast</td><td><i> </i></td><td></td></tr>
- <tr><td><a href="https://wg21.link/P1645">P1645</a></td><td>LWG</td><td>constexpr for numeric algorithms </td><td>Belfast</td><td><i> </i></td><td></td></tr>
+ <tr><td><a href="https://wg21.link/P1645">P1645</a></td><td>LWG</td><td>constexpr for numeric algorithms </td><td>Belfast</td><td>Complete</td><td>12.0</td></tr>
<tr><td><a href="https://wg21.link/P1664">P1664</a></td><td>LWG</td><td>reconstructible_range - a concept for putting ranges back together </td><td>Belfast</td><td><i> </i></td><td></td></tr>
<tr><td><a href="https://wg21.link/P1686">P1686</a></td><td>LWG</td><td>Mandating the Standard Library: Clause 27 - Time library </td><td>Belfast</td><td><i> </i></td><td></td></tr>
<tr><td><a href="https://wg21.link/P1690">P1690</a></td><td>LWG</td><td>Refinement Proposal for P0919 Heterogeneous lookup for unordered containers </td><td>Belfast</td><td>Complete</td><td>12.0</td></tr>