brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 8cb49b1 Raw
52 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <numeric>10 11// Became constexpr in C++2012// template <class ForwardIterator, class T>13//     void iota(ForwardIterator first, ForwardIterator last, T value);14 15#include <numeric>16#include <cassert>17 18#include "test_macros.h"19#include "test_iterators.h"20 21template <class InIter>22TEST_CONSTEXPR_CXX20 void23test()24{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]);31}32 33TEST_CONSTEXPR_CXX20 bool34test()35{36    test<forward_iterator<int*> >();37    test<bidirectional_iterator<int*> >();38    test<random_access_iterator<int*> >();39    test<int*>();40 41    return true;42}43 44int main(int, char**)45{46    test();47#if TEST_STD_VER > 1748    static_assert(test());49#endif50    return 0;51}52