xref: /freebsd-src/contrib/llvm-project/libcxx/include/__memory/concepts.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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>
22*06c3fb27SDimitry 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 
30*06c3fb27SDimitry 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 =
400eae32dcSDimitry Andric     input_iterator<_Ip> &&
410eae32dcSDimitry Andric     is_lvalue_reference_v<iter_reference_t<_Ip>> &&
420eae32dcSDimitry Andric     same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
430eae32dcSDimitry Andric 
440eae32dcSDimitry Andric template <class _Sp, class _Ip>
450eae32dcSDimitry Andric concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
460eae32dcSDimitry Andric 
470eae32dcSDimitry Andric template <class _Rp>
480eae32dcSDimitry Andric concept __nothrow_input_range =
490eae32dcSDimitry Andric     range<_Rp> &&
500eae32dcSDimitry Andric     __nothrow_input_iterator<iterator_t<_Rp>> &&
510eae32dcSDimitry Andric     __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
520eae32dcSDimitry Andric 
530eae32dcSDimitry Andric template <class _Ip>
540eae32dcSDimitry Andric concept __nothrow_forward_iterator =
550eae32dcSDimitry Andric     __nothrow_input_iterator<_Ip> &&
560eae32dcSDimitry Andric     forward_iterator<_Ip> &&
570eae32dcSDimitry Andric     __nothrow_sentinel_for<_Ip, _Ip>;
580eae32dcSDimitry Andric 
590eae32dcSDimitry Andric template <class _Rp>
600eae32dcSDimitry Andric concept __nothrow_forward_range =
610eae32dcSDimitry Andric     __nothrow_input_range<_Rp> &&
620eae32dcSDimitry Andric     __nothrow_forward_iterator<iterator_t<_Rp>>;
630eae32dcSDimitry Andric 
640eae32dcSDimitry Andric } // namespace ranges
65d56accc7SDimitry Andric 
66*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
670eae32dcSDimitry Andric 
680eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_STD
690eae32dcSDimitry Andric 
700eae32dcSDimitry Andric #endif // _LIBCPP___MEMORY_CONCEPTS_H
71