diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:07:56 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:07:56 +0000 |
| commit | f36202620b428c45a1c8d91743727c9313424fb2 (patch) | |
| tree | 14928d8970ba4890a6370aca4c38fc832d45f21f /test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp | |
| parent | 0294ba5648d889e48ffee8ddad25944e258940ae (diff) | |
Notes
Diffstat (limited to 'test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp')
| -rw-r--r-- | test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp index f39436048aef..1e962990b8fe 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp +++ b/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 } |
