diff options
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.fill')
-rw-r--r-- | libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp | 18 | ||||
-rw-r--r-- | libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp | 20 |
2 files changed, 36 insertions, 2 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp index c72adac9e2e..8b9e109d7be 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp @@ -11,14 +11,26 @@ // template<ForwardIterator Iter, class T> // requires OutputIterator<Iter, const T&> -// void +// constexpr void // constexpr after C++17 // fill(Iter first, Iter last, const T& value); #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + int ia[] = {0, 1, 2, 3, 4}; + + std::fill(std::begin(ia), std::end(ia), 5); + + return std::all_of(std::begin(ia), std::end(ia), [](int a) {return a == 5; }) + ; + } +#endif + template <class Iter> void test_char() @@ -56,4 +68,8 @@ int main() test_int<bidirectional_iterator<int*> >(); test_int<random_access_iterator<int*> >(); test_int<int*>(); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp index f39436048ae..fea7165af7b 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp @@ -11,15 +11,29 @@ // template<class Iter, IntegralLike Size, class T> // requires OutputIterator<Iter, const T&> -// OutputIterator +// constexpr OutputIterator // constexpr after C++17 // fill_n(Iter first, Size n, const T& value); #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" #include "user_defined_integral.hpp" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + const size_t N = 5; + int ib[] = {0, 0, 0, 0, 0, 0}; // one bigger than N + + auto it = std::fill_n(std::begin(ib), N, 5); + return it == (std::begin(ib) + N) + && std::all_of(std::begin(ib), it, [](int a) {return a == 5; }) + && *it == 0 // don't overwrite the last value in the output array + ; + } +#endif + typedef UserDefinedIntegral<unsigned> UDI; template <class Iter> @@ -153,4 +167,8 @@ int main() test5(); test6(); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |