Пример #1
0
    void iterate_every_other_element(multi_span<int, dynamic_range> av)
    {
        // pick every other element

        auto length = av.size() / 2;
#if _MSC_VER > 1800
        auto bounds = strided_bounds<1>({length}, {2});
#else
        auto bounds = strided_bounds<1>(index<1>{ length }, index<1>{ 2 });
#endif
        strided_span<int, 1> strided(&av.data()[1], av.size() - 1, bounds);

        CHECK(strided.size() == length);
        CHECK(strided.bounds().index_bounds()[0] == length);
        for (auto i = 0; i < strided.size(); ++i)
        {
            CHECK(strided[i] == av[2 * i + 1]);
        }

        int idx = 0;
        for (auto num : strided)
        {
            CHECK(num == av[2 * idx + 1]);
            idx++;
        }
    }