1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template<ForwardIterator Iter, Callable Generator>
12 // requires OutputIterator<Iter, Generator::result_type>
13 // && CopyConstructible<Generator>
14 // constexpr void // constexpr after c++17
15 // generate(Iter first, Iter last, Generator gen);
20 #include "test_macros.h"
21 #include "test_iterators.h"
25 TEST_CONSTEXPR
int operator()() const {return 1;}
30 TEST_CONSTEXPR
bool test_constexpr() {
31 int ia
[] = {0, 1, 2, 3, 4};
33 std::generate(std::begin(ia
), std::end(ia
), gen_test());
35 return std::all_of(std::begin(ia
), std::end(ia
), [](int x
) { return x
== 1; })
47 std::generate(Iter(ia
), Iter(ia
+n
), gen_test());
56 test
<forward_iterator
<int*> >();
57 test
<bidirectional_iterator
<int*> >();
58 test
<random_access_iterator
<int*> >();
62 static_assert(test_constexpr());