diff options
Diffstat (limited to 'libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp')
-rw-r--r-- | libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp b/libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp index 044b70d4f9a1..0f3be386e05d 100644 --- a/libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp @@ -8,7 +8,9 @@ // <numeric> // UNSUPPORTED: c++03, c++11, c++14 +// UNSUPPORTED: clang-8 +// Became constexpr in C++20 // template<class InputIterator, class T, class BinaryOperation> // T reduce(InputIterator first, InputIterator last, T init, BinaryOperation op); @@ -19,7 +21,7 @@ #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))>, "" ); @@ -27,7 +29,7 @@ test(Iter first, Iter last, T init, Op op, T x) } template <class Iter> -void +TEST_CONSTEXPR_CXX20 void test() { int ia[] = {1, 2, 3, 4, 5, 6}; @@ -43,13 +45,15 @@ test() } 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>(); @@ -72,5 +76,14 @@ int main(int, char**) 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; } |