Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/__iterator/concepts.h
// -*- C++ -*- | // -*- C++ -*- | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef _LIBCPP___ITERATOR_CONCEPTS_H | #ifndef _LIBCPP___ITERATOR_CONCEPTS_H | ||||
#define _LIBCPP___ITERATOR_CONCEPTS_H | #define _LIBCPP___ITERATOR_CONCEPTS_H | ||||
#include <__config> | #include <__config> | ||||
#include <concepts> | #include <concepts> | ||||
#include <__iterator/iter_move.h> | #include <__iterator/iter_move.h> | ||||
#include <__iterator/incrementable_traits.h> | #include <__iterator/incrementable_traits.h> | ||||
Quuxplusone: At some point: Alphabetize. | |||||
#include <__iterator/iterator_traits.h> | #include <__iterator/iterator_traits.h> | ||||
#include <__iterator/readable_traits.h> | #include <__iterator/readable_traits.h> | ||||
#include <__memory/pointer_traits.h> | |||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||||
#pragma GCC system_header | #pragma GCC system_header | ||||
#endif | #endif | ||||
_LIBCPP_PUSH_MACROS | _LIBCPP_PUSH_MACROS | ||||
#include <__undef_macros> | #include <__undef_macros> | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | requires(_Ip __i, const _Ip __j, const iter_difference_t<_Ip> __n) { | ||||
{ __i += __n } -> same_as<_Ip&>; | { __i += __n } -> same_as<_Ip&>; | ||||
{ __j + __n } -> same_as<_Ip>; | { __j + __n } -> same_as<_Ip>; | ||||
{ __n + __j } -> same_as<_Ip>; | { __n + __j } -> same_as<_Ip>; | ||||
{ __i -= __n } -> same_as<_Ip&>; | { __i -= __n } -> same_as<_Ip&>; | ||||
{ __j - __n } -> same_as<_Ip>; | { __j - __n } -> same_as<_Ip>; | ||||
{ __j[__n] } -> same_as<iter_reference_t<_Ip>>; | { __j[__n] } -> same_as<iter_reference_t<_Ip>>; | ||||
}; | }; | ||||
template<class _Ip> | |||||
concept contiguous_iterator = | |||||
random_access_iterator<_Ip> && | |||||
derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> && | |||||
is_lvalue_reference_v<iter_reference_t<_Ip>> && | |||||
same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>> && | |||||
// This condition isn't required, but allows `contiguous_iterator` to be SFINAE friendly | |||||
// which improves the QoI. | |||||
(is_pointer_v<_Ip> || requires { sizeof(__pointer_traits_element_type<_Ip>); }) && | |||||
requires(const _Ip& __i) { | |||||
{ _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>; | |||||
}; | |||||
// clang-format on | // clang-format on | ||||
#endif // !defined(_LIBCPP_HAS_NO_RANGES) | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | ||||
_LIBCPP_END_NAMESPACE_STD | _LIBCPP_END_NAMESPACE_STD | ||||
_LIBCPP_POP_MACROS | _LIBCPP_POP_MACROS | ||||
#endif // _LIBCPP___ITERATOR_CONCEPTS_H | #endif // _LIBCPP___ITERATOR_CONCEPTS_H |
At some point: Alphabetize.