1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <numeric> 10 // UNSUPPORTED: clang-8 11 // UNSUPPORTED: gcc-9 12 13 // Became constexpr in C++20 14 // template <class ForwardIterator, class T> 15 // void iota(ForwardIterator first, ForwardIterator last, T value); 16 17 #include <numeric> 18 #include <cassert> 19 20 #include "test_macros.h" 21 #include "test_iterators.h" 22 23 template <class InIter> 24 TEST_CONSTEXPR_CXX20 void 25 test() 26 { 27 int ia[] = {1, 2, 3, 4, 5}; 28 int ir[] = {5, 6, 7, 8, 9}; 29 const unsigned s = sizeof(ia) / sizeof(ia[0]); 30 std::iota(InIter(ia), InIter(ia+s), 5); 31 for (unsigned i = 0; i < s; ++i) 32 assert(ia[i] == ir[i]); 33 } 34 35 TEST_CONSTEXPR_CXX20 bool 36 test() 37 { 38 test<forward_iterator<int*> >(); 39 test<bidirectional_iterator<int*> >(); 40 test<random_access_iterator<int*> >(); 41 test<int*>(); 42 43 return true; 44 } 45 46 int main(int, char**) 47 { 48 test(); 49 #if TEST_STD_VER > 17 50 static_assert(test()); 51 #endif 52 return 0; 53 } 54