xref: /freebsd-src/contrib/llvm-project/libcxx/include/__memory/concepts.h (revision cb14a3fe5122c879eae1fb480ed7ce82a699ddb6)
10eae32dcSDimitry Andric // -*- C++ -*-
20eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
30eae32dcSDimitry Andric //
40eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
60eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70eae32dcSDimitry Andric //
80eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
90eae32dcSDimitry Andric 
100eae32dcSDimitry Andric #ifndef _LIBCPP___MEMORY_CONCEPTS_H
110eae32dcSDimitry Andric #define _LIBCPP___MEMORY_CONCEPTS_H
120eae32dcSDimitry Andric 
13bdd1243dSDimitry Andric #include <__concepts/same_as.h>
140eae32dcSDimitry Andric #include <__config>
150eae32dcSDimitry Andric #include <__iterator/concepts.h>
160eae32dcSDimitry Andric #include <__iterator/iterator_traits.h>
170eae32dcSDimitry Andric #include <__iterator/readable_traits.h>
180eae32dcSDimitry Andric #include <__ranges/access.h>
190eae32dcSDimitry Andric #include <__ranges/concepts.h>
20bdd1243dSDimitry Andric #include <__type_traits/is_reference.h>
21bdd1243dSDimitry Andric #include <__type_traits/remove_cvref.h>
2206c3fb27SDimitry Andric #include <__type_traits/remove_reference.h> // TODO(modules): This should not be required
230eae32dcSDimitry Andric 
240eae32dcSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
250eae32dcSDimitry Andric #  pragma GCC system_header
260eae32dcSDimitry Andric #endif
270eae32dcSDimitry Andric 
280eae32dcSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
290eae32dcSDimitry Andric 
3006c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20
31d56accc7SDimitry Andric 
320eae32dcSDimitry Andric namespace ranges {
330eae32dcSDimitry Andric 
340eae32dcSDimitry Andric // [special.mem.concepts]
350eae32dcSDimitry Andric 
360eae32dcSDimitry Andric // This concept ensures that uninitialized algorithms can construct an object
370eae32dcSDimitry Andric // at the address pointed-to by the iterator, which requires an lvalue.
380eae32dcSDimitry Andric template <class _Ip>
390eae32dcSDimitry Andric concept __nothrow_input_iterator =
40*cb14a3feSDimitry Andric     input_iterator<_Ip> && is_lvalue_reference_v<iter_reference_t<_Ip>> &&
410eae32dcSDimitry Andric     same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
420eae32dcSDimitry Andric 
430eae32dcSDimitry Andric template <class _Sp, class _Ip>
440eae32dcSDimitry Andric concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
450eae32dcSDimitry Andric 
460eae32dcSDimitry Andric template <class _Rp>
470eae32dcSDimitry Andric concept __nothrow_input_range =
48*cb14a3feSDimitry Andric     range<_Rp> && __nothrow_input_iterator<iterator_t<_Rp>> && __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
490eae32dcSDimitry Andric 
500eae32dcSDimitry Andric template <class _Ip>
510eae32dcSDimitry Andric concept __nothrow_forward_iterator =
52*cb14a3feSDimitry Andric     __nothrow_input_iterator<_Ip> && forward_iterator<_Ip> && __nothrow_sentinel_for<_Ip, _Ip>;
530eae32dcSDimitry Andric 
540eae32dcSDimitry Andric template <class _Rp>
55*cb14a3feSDimitry Andric concept __nothrow_forward_range = __nothrow_input_range<_Rp> && __nothrow_forward_iterator<iterator_t<_Rp>>;
560eae32dcSDimitry Andric 
570eae32dcSDimitry Andric } // namespace ranges
58d56accc7SDimitry Andric 
5906c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
600eae32dcSDimitry Andric 
610eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_STD
620eae32dcSDimitry Andric 
630eae32dcSDimitry Andric #endif // _LIBCPP___MEMORY_CONCEPTS_H
64