1 | // -*- C++ -*- |
2 | //===----------------------------------------------------------------------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP___MEMORY_CONCEPTS_H |
11 | #define _LIBCPP___MEMORY_CONCEPTS_H |
12 | |
13 | #include <__concepts/same_as.h> |
14 | #include <__config> |
15 | #include <__iterator/concepts.h> |
16 | #include <__iterator/iterator_traits.h> |
17 | #include <__iterator/readable_traits.h> |
18 | #include <__ranges/access.h> |
19 | #include <__ranges/concepts.h> |
20 | #include <__type_traits/is_reference.h> |
21 | #include <__type_traits/remove_cvref.h> |
22 | #include <__type_traits/remove_reference.h> // TODO(modules): This should not be required |
23 | |
24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
25 | # pragma GCC system_header |
26 | #endif |
27 | |
28 | _LIBCPP_BEGIN_NAMESPACE_STD |
29 | |
30 | #if _LIBCPP_STD_VER >= 20 |
31 | |
32 | namespace ranges { |
33 | |
34 | // [special.mem.concepts] |
35 | |
36 | // This concept ensures that uninitialized algorithms can construct an object |
37 | // at the address pointed-to by the iterator, which requires an lvalue. |
38 | template <class _Ip> |
39 | concept __nothrow_input_iterator = |
40 | input_iterator<_Ip> && is_lvalue_reference_v<iter_reference_t<_Ip>> && |
41 | same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>; |
42 | |
43 | template <class _Sp, class _Ip> |
44 | concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>; |
45 | |
46 | template <class _Rp> |
47 | concept __nothrow_input_range = |
48 | range<_Rp> && __nothrow_input_iterator<iterator_t<_Rp>> && __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>; |
49 | |
50 | template <class _Ip> |
51 | concept __nothrow_forward_iterator = |
52 | __nothrow_input_iterator<_Ip> && forward_iterator<_Ip> && __nothrow_sentinel_for<_Ip, _Ip>; |
53 | |
54 | template <class _Rp> |
55 | concept __nothrow_forward_range = __nothrow_input_range<_Rp> && __nothrow_forward_iterator<iterator_t<_Rp>>; |
56 | |
57 | } // namespace ranges |
58 | |
59 | #endif // _LIBCPP_STD_VER >= 20 |
60 | |
61 | _LIBCPP_END_NAMESPACE_STD |
62 | |
63 | #endif // _LIBCPP___MEMORY_CONCEPTS_H |
64 | |