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 <__config>
14 #include <__iterator/concepts.h>
15 #include <__iterator/iterator_traits.h>
16 #include <__iterator/readable_traits.h>
17 #include <__ranges/access.h>
18 #include <__ranges/concepts.h>
19 #include <concepts>
20 #include <type_traits>
21 
22 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23 #  pragma GCC system_header
24 #endif
25 
26 _LIBCPP_BEGIN_NAMESPACE_STD
27 
28 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29 
30 namespace ranges {
31 
32 // [special.mem.concepts]
33 
34 // This concept ensures that uninitialized algorithms can construct an object
35 // at the address pointed-to by the iterator, which requires an lvalue.
36 template <class _Ip>
37 concept __nothrow_input_iterator =
38     input_iterator<_Ip> &&
39     is_lvalue_reference_v<iter_reference_t<_Ip>> &&
40     same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
41 
42 template <class _Sp, class _Ip>
43 concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
44 
45 template <class _Rp>
46 concept __nothrow_input_range =
47     range<_Rp> &&
48     __nothrow_input_iterator<iterator_t<_Rp>> &&
49     __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
50 
51 template <class _Ip>
52 concept __nothrow_forward_iterator =
53     __nothrow_input_iterator<_Ip> &&
54     forward_iterator<_Ip> &&
55     __nothrow_sentinel_for<_Ip, _Ip>;
56 
57 template <class _Rp>
58 concept __nothrow_forward_range =
59     __nothrow_input_range<_Rp> &&
60     __nothrow_forward_iterator<iterator_t<_Rp>>;
61 
62 } // namespace ranges
63 
64 #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65 
66 _LIBCPP_END_NAMESPACE_STD
67 
68 #endif // _LIBCPP___MEMORY_CONCEPTS_H
69