Files
clang-p2996/libcxx/test/support/test_range.h
Christopher Di Bella 773ae44124 [libcxx][nfc] prefixes test type input_iterator with cpp17_
C++20 revised the definition of what it means to be an iterator. While
all _Cpp17InputIterators_ satisfy `std::input_iterator`, the reverse
isn't true. D100271 introduces a new test adaptor to accommodate this
new definition (`cpp20_input_iterator`).

In order to help readers immediately distinguish which input iterator
adaptor is _Cpp17InputIterator_, the current `input_iterator` adaptor
has been prefixed with `cpp17_`.

Differential Revision: https://reviews.llvm.org/D101242
2021-05-02 05:02:59 +00:00

60 lines
1.5 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LIBCXX_TEST_SUPPORT_TEST_RANGE_H
#define LIBCXX_TEST_SUPPORT_TEST_RANGE_H
#include <iterator>
#include <ranges>
#include "test_iterators.h"
#ifdef _LIBCPP_HAS_NO_RANGES
#error "test/suppoort/test_range.h" can only be included in builds supporting ranges
#endif
struct sentinel {
bool operator==(std::input_or_output_iterator auto const&) const;
};
// clang-format off
template <template <class...> class I>
requires std::input_or_output_iterator<I<int*> >
struct test_range {
I<int*> begin();
I<int const*> begin() const;
sentinel end();
sentinel end() const;
};
template <template <class...> class I>
requires std::input_or_output_iterator<I<int*> >
struct test_non_const_range {
I<int*> begin();
sentinel end();
};
template <template <class...> class I>
requires std::input_or_output_iterator<I<int*> >
struct test_common_range {
I<int*> begin();
I<int const*> begin() const;
I<int*> end();
I<int const*> end() const;
};
template <template <class...> class I>
requires std::input_or_output_iterator<I<int*> >
struct test_non_const_common_range {
I<int*> begin();
I<int*> end();
};
// clang-format on
#endif // LIBCXX_TEST_SUPPORT_TEST_RANGE_H