xref: /freebsd-src/contrib/llvm-project/libcxx/include/__memory/concepts.h (revision d56accc7c3dcc897489b6a07834763a03b9f3d68)
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 
130eae32dcSDimitry Andric #include <__config>
140eae32dcSDimitry Andric #include <__iterator/concepts.h>
150eae32dcSDimitry Andric #include <__iterator/iterator_traits.h>
160eae32dcSDimitry Andric #include <__iterator/readable_traits.h>
170eae32dcSDimitry Andric #include <__ranges/access.h>
180eae32dcSDimitry Andric #include <__ranges/concepts.h>
190eae32dcSDimitry Andric #include <concepts>
200eae32dcSDimitry Andric #include <type_traits>
210eae32dcSDimitry Andric 
220eae32dcSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
230eae32dcSDimitry Andric #pragma GCC system_header
240eae32dcSDimitry Andric #endif
250eae32dcSDimitry Andric 
260eae32dcSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
270eae32dcSDimitry Andric 
28*d56accc7SDimitry Andric #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29*d56accc7SDimitry Andric 
300eae32dcSDimitry Andric namespace ranges {
310eae32dcSDimitry Andric 
320eae32dcSDimitry Andric // [special.mem.concepts]
330eae32dcSDimitry Andric 
340eae32dcSDimitry Andric // This concept ensures that uninitialized algorithms can construct an object
350eae32dcSDimitry Andric // at the address pointed-to by the iterator, which requires an lvalue.
360eae32dcSDimitry Andric template <class _Ip>
370eae32dcSDimitry Andric concept __nothrow_input_iterator =
380eae32dcSDimitry Andric     input_iterator<_Ip> &&
390eae32dcSDimitry Andric     is_lvalue_reference_v<iter_reference_t<_Ip>> &&
400eae32dcSDimitry Andric     same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
410eae32dcSDimitry Andric 
420eae32dcSDimitry Andric template <class _Sp, class _Ip>
430eae32dcSDimitry Andric concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
440eae32dcSDimitry Andric 
450eae32dcSDimitry Andric template <class _Rp>
460eae32dcSDimitry Andric concept __nothrow_input_range =
470eae32dcSDimitry Andric     range<_Rp> &&
480eae32dcSDimitry Andric     __nothrow_input_iterator<iterator_t<_Rp>> &&
490eae32dcSDimitry Andric     __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
500eae32dcSDimitry Andric 
510eae32dcSDimitry Andric template <class _Ip>
520eae32dcSDimitry Andric concept __nothrow_forward_iterator =
530eae32dcSDimitry Andric     __nothrow_input_iterator<_Ip> &&
540eae32dcSDimitry Andric     forward_iterator<_Ip> &&
550eae32dcSDimitry Andric     __nothrow_sentinel_for<_Ip, _Ip>;
560eae32dcSDimitry Andric 
570eae32dcSDimitry Andric template <class _Rp>
580eae32dcSDimitry Andric concept __nothrow_forward_range =
590eae32dcSDimitry Andric     __nothrow_input_range<_Rp> &&
600eae32dcSDimitry Andric     __nothrow_forward_iterator<iterator_t<_Rp>>;
610eae32dcSDimitry Andric 
620eae32dcSDimitry Andric } // namespace ranges
63*d56accc7SDimitry Andric 
64*d56accc7SDimitry Andric #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
650eae32dcSDimitry Andric 
660eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_STD
670eae32dcSDimitry Andric 
680eae32dcSDimitry Andric #endif // _LIBCPP___MEMORY_CONCEPTS_H
69