xref: /freebsd-src/contrib/llvm-project/libcxx/include/__memory/concepts.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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 
13*bdd1243dSDimitry 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>
20*bdd1243dSDimitry Andric #include <__type_traits/is_reference.h>
21*bdd1243dSDimitry Andric #include <__type_traits/remove_cvref.h>
220eae32dcSDimitry Andric 
230eae32dcSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
240eae32dcSDimitry Andric #  pragma GCC system_header
250eae32dcSDimitry Andric #endif
260eae32dcSDimitry Andric 
270eae32dcSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
280eae32dcSDimitry Andric 
29*bdd1243dSDimitry Andric #if _LIBCPP_STD_VER > 17
30d56accc7SDimitry Andric 
310eae32dcSDimitry Andric namespace ranges {
320eae32dcSDimitry Andric 
330eae32dcSDimitry Andric // [special.mem.concepts]
340eae32dcSDimitry Andric 
350eae32dcSDimitry Andric // This concept ensures that uninitialized algorithms can construct an object
360eae32dcSDimitry Andric // at the address pointed-to by the iterator, which requires an lvalue.
370eae32dcSDimitry Andric template <class _Ip>
380eae32dcSDimitry Andric concept __nothrow_input_iterator =
390eae32dcSDimitry Andric     input_iterator<_Ip> &&
400eae32dcSDimitry Andric     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 =
480eae32dcSDimitry Andric     range<_Rp> &&
490eae32dcSDimitry Andric     __nothrow_input_iterator<iterator_t<_Rp>> &&
500eae32dcSDimitry Andric     __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
510eae32dcSDimitry Andric 
520eae32dcSDimitry Andric template <class _Ip>
530eae32dcSDimitry Andric concept __nothrow_forward_iterator =
540eae32dcSDimitry Andric     __nothrow_input_iterator<_Ip> &&
550eae32dcSDimitry Andric     forward_iterator<_Ip> &&
560eae32dcSDimitry Andric     __nothrow_sentinel_for<_Ip, _Ip>;
570eae32dcSDimitry Andric 
580eae32dcSDimitry Andric template <class _Rp>
590eae32dcSDimitry Andric concept __nothrow_forward_range =
600eae32dcSDimitry Andric     __nothrow_input_range<_Rp> &&
610eae32dcSDimitry Andric     __nothrow_forward_iterator<iterator_t<_Rp>>;
620eae32dcSDimitry Andric 
630eae32dcSDimitry Andric } // namespace ranges
64d56accc7SDimitry Andric 
65*bdd1243dSDimitry Andric #endif // _LIBCPP_STD_VER > 17
660eae32dcSDimitry Andric 
670eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_STD
680eae32dcSDimitry Andric 
690eae32dcSDimitry Andric #endif // _LIBCPP___MEMORY_CONCEPTS_H
70