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 // Became constexpr in C++20
12 // template <class ForwardIterator, class T>
13 // void iota(ForwardIterator first, ForwardIterator last, T value);
18 #include "test_macros.h"
19 #include "test_iterators.h"
21 template <class InIter
>
22 TEST_CONSTEXPR_CXX20
void
25 int ia
[] = {1, 2, 3, 4, 5};
26 int ir
[] = {5, 6, 7, 8, 9};
27 const unsigned s
= sizeof(ia
) / sizeof(ia
[0]);
28 std::iota(InIter(ia
), InIter(ia
+s
), 5);
29 for (unsigned i
= 0; i
< s
; ++i
)
30 assert(ia
[i
] == ir
[i
]);
33 TEST_CONSTEXPR_CXX20
bool
36 test
<forward_iterator
<int*> >();
37 test
<bidirectional_iterator
<int*> >();
38 test
<random_access_iterator
<int*> >();
48 static_assert(test());