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