Beispiel #1
0
int main()
{
    test<input_iterator<const int*>, output_iterator<int*> >();
    test<input_iterator<const int*>, forward_iterator<int*> >();
    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
    test<input_iterator<const int*>, random_access_iterator<int*> >();
    test<input_iterator<const int*>, int*>();

    test<forward_iterator<const int*>, output_iterator<int*> >();
    test<forward_iterator<const int*>, forward_iterator<int*> >();
    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
    test<forward_iterator<const int*>, random_access_iterator<int*> >();
    test<forward_iterator<const int*>, int*>();

    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
    test<bidirectional_iterator<const int*>, int*>();

    test<random_access_iterator<const int*>, output_iterator<int*> >();
    test<random_access_iterator<const int*>, forward_iterator<int*> >();
    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
    test<random_access_iterator<const int*>, int*>();

    test<const int*, output_iterator<int*> >();
    test<const int*, forward_iterator<int*> >();
    test<const int*, bidirectional_iterator<int*> >();
    test<const int*, random_access_iterator<int*> >();
    test<const int*, int*>();

    // Test projections:
    {
        S const ia[] = {{1,1},{2,2},{3,3},{3,4},{4,5},{5,6},{5,7},{5,8},{6,9},{7,10}};
        S ib[ranges::size(ia)];
        ranges::unique_copy_result<S const *, S *> r = ranges::unique_copy(ia, ib, ranges::equal_to(), &S::i);
        CHECK(r.in == ranges::end(ia));
        CHECK(r.out == ib + 7);
        check_equal(ranges::make_subrange(ib, ib+7), {S{1,1},S{2,2},S{3,3},S{4,5},S{5,6},S{6,9},S{7,10}});
    }

    // Test rvalue ranges:
    {
        S const ia[] = {{1,1},{2,2},{3,3},{3,4},{4,5},{5,6},{5,7},{5,8},{6,9},{7,10}};
        S ib[ranges::size(ia)];
        auto r = ranges::unique_copy(ranges::view::all(ia), ib, ranges::equal_to(), &S::i);
        CHECK(r.in == ranges::end(ia));
        CHECK(r.out == ib + 7);
        check_equal(ranges::make_subrange(ib, ib+7), {S{1,1},S{2,2},S{3,3},S{4,5},S{5,6},S{6,9},S{7,10}});
    }
#ifndef RANGES_WORKAROUND_MSVC_573728
    {
        S const ia[] = {{1,1},{2,2},{3,3},{3,4},{4,5},{5,6},{5,7},{5,8},{6,9},{7,10}};
        S ib[ranges::size(ia)];
        auto r = ranges::unique_copy(std::move(ia), ib, ranges::equal_to(), &S::i);
        CHECK(::is_dangling(r.in));
        CHECK(r.out == ib + 7);
        check_equal(ranges::make_subrange(ib, ib+7), {S{1,1},S{2,2},S{3,3},S{4,5},S{5,6},S{6,9},S{7,10}});
    }
#endif // RANGES_WORKAROUND_MSVC_573728
    {
        std::vector<S> const ia{{1,1},{2,2},{3,3},{3,4},{4,5},{5,6},{5,7},{5,8},{6,9},{7,10}};
        S ib[10];
        RANGES_ENSURE(ranges::size(ia) == ranges::size(ib));
        auto r = ranges::unique_copy(std::move(ia), ib, ranges::equal_to(), &S::i);
        CHECK(::is_dangling(r.in));
        CHECK(r.out == ib + 7);
        check_equal(ranges::make_subrange(ib, ib+7), {S{1,1},S{2,2},S{3,3},S{4,5},S{5,6},S{6,9},S{7,10}});
    }

    return ::test_result();
}
Beispiel #2
0
 constexpr friend diffmax_t operator<<(diffmax_t a, diffmax_t b) noexcept
 {
     RANGES_ENSURE(!a.neg_);
     return b.neg_ ? diffmax_t{tag{}, false, a.val_ >> b.val_}
                   : diffmax_t{tag{}, false, a.val_ << b.val_};
Beispiel #3
0
 [[noreturn]] void apply(std::size_t, Fun &&, meta::size_t<N> = meta::size_t<N>{}) const
 {
     RANGES_ENSURE(false);
 }
Beispiel #4
0
 [[noreturn]] bool equal(std::size_t, variant_data const &) const
 {
     RANGES_ENSURE(false);
 }
Beispiel #5
0
 [[noreturn]] void move_copy_construct(std::size_t, That &&) const
 {
     RANGES_ENSURE(false);
 }
Beispiel #6
0
 [[noreturn]] inline void apply_if(any, any, any)
 {
     RANGES_ENSURE(false);
 }