aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp')
-rw-r--r--libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp b/libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp
index adcdcaac26ca..88e2e24b605a 100644
--- a/libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/reduce/reduce.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>
// typename iterator_traits<InputIterator>::value_type
// reduce(InputIterator first, InputIterator last);
@@ -20,7 +22,7 @@
#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,
@@ -29,7 +31,7 @@ test(Iter first, Iter last, T x)
}
template <class Iter>
-void
+TEST_CONSTEXPR_CXX20 void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
@@ -41,13 +43,15 @@ test()
}
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>();
@@ -61,5 +65,14 @@ int main(int, char**)
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;
}