xref: /llvm-project/libcxx/include/__memory/concepts.h (revision 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7)
12d9efcfeSKonstantin Varlamov // -*- C++ -*-
22d9efcfeSKonstantin Varlamov //===----------------------------------------------------------------------===//
32d9efcfeSKonstantin Varlamov //
42d9efcfeSKonstantin Varlamov // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
52d9efcfeSKonstantin Varlamov // See https://llvm.org/LICENSE.txt for license information.
62d9efcfeSKonstantin Varlamov // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
72d9efcfeSKonstantin Varlamov //
82d9efcfeSKonstantin Varlamov //===----------------------------------------------------------------------===//
92d9efcfeSKonstantin Varlamov 
102d9efcfeSKonstantin Varlamov #ifndef _LIBCPP___MEMORY_CONCEPTS_H
112d9efcfeSKonstantin Varlamov #define _LIBCPP___MEMORY_CONCEPTS_H
122d9efcfeSKonstantin Varlamov 
1389b356f0SNikolas Klauser #include <__concepts/same_as.h>
142d9efcfeSKonstantin Varlamov #include <__config>
152d9efcfeSKonstantin Varlamov #include <__iterator/concepts.h>
162d9efcfeSKonstantin Varlamov #include <__iterator/iterator_traits.h>
172d9efcfeSKonstantin Varlamov #include <__iterator/readable_traits.h>
182d9efcfeSKonstantin Varlamov #include <__ranges/access.h>
192d9efcfeSKonstantin Varlamov #include <__ranges/concepts.h>
20e0a66116SNikolas Klauser #include <__type_traits/is_reference.h>
21e0a66116SNikolas Klauser #include <__type_traits/remove_cvref.h>
2240cdb220SIan Anderson #include <__type_traits/remove_reference.h> // TODO(modules): This should not be required
232d9efcfeSKonstantin Varlamov 
242d9efcfeSKonstantin Varlamov #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
252d9efcfeSKonstantin Varlamov #  pragma GCC system_header
262d9efcfeSKonstantin Varlamov #endif
272d9efcfeSKonstantin Varlamov 
282d9efcfeSKonstantin Varlamov _LIBCPP_BEGIN_NAMESPACE_STD
292d9efcfeSKonstantin Varlamov 
304f15267dSNikolas Klauser #if _LIBCPP_STD_VER >= 20
3153406fb6SArthur O'Dwyer 
322d9efcfeSKonstantin Varlamov namespace ranges {
332d9efcfeSKonstantin Varlamov 
342d9efcfeSKonstantin Varlamov // [special.mem.concepts]
352d9efcfeSKonstantin Varlamov 
362d9efcfeSKonstantin Varlamov // This concept ensures that uninitialized algorithms can construct an object
372d9efcfeSKonstantin Varlamov // at the address pointed-to by the iterator, which requires an lvalue.
382d9efcfeSKonstantin Varlamov template <class _Ip>
392d9efcfeSKonstantin Varlamov concept __nothrow_input_iterator =
40*9783f28cSLouis Dionne     input_iterator<_Ip> && is_lvalue_reference_v<iter_reference_t<_Ip>> &&
412d9efcfeSKonstantin Varlamov     same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
422d9efcfeSKonstantin Varlamov 
432d9efcfeSKonstantin Varlamov template <class _Sp, class _Ip>
442d9efcfeSKonstantin Varlamov concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
452d9efcfeSKonstantin Varlamov 
462d9efcfeSKonstantin Varlamov template <class _Rp>
472d9efcfeSKonstantin Varlamov concept __nothrow_input_range =
48*9783f28cSLouis Dionne     range<_Rp> && __nothrow_input_iterator<iterator_t<_Rp>> && __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
492d9efcfeSKonstantin Varlamov 
502d9efcfeSKonstantin Varlamov template <class _Ip>
512d9efcfeSKonstantin Varlamov concept __nothrow_forward_iterator =
52*9783f28cSLouis Dionne     __nothrow_input_iterator<_Ip> && forward_iterator<_Ip> && __nothrow_sentinel_for<_Ip, _Ip>;
532d9efcfeSKonstantin Varlamov 
542d9efcfeSKonstantin Varlamov template <class _Rp>
55*9783f28cSLouis Dionne concept __nothrow_forward_range = __nothrow_input_range<_Rp> && __nothrow_forward_iterator<iterator_t<_Rp>>;
562d9efcfeSKonstantin Varlamov 
572d9efcfeSKonstantin Varlamov } // namespace ranges
5853406fb6SArthur O'Dwyer 
594f15267dSNikolas Klauser #endif // _LIBCPP_STD_VER >= 20
602d9efcfeSKonstantin Varlamov 
612d9efcfeSKonstantin Varlamov _LIBCPP_END_NAMESPACE_STD
622d9efcfeSKonstantin Varlamov 
632d9efcfeSKonstantin Varlamov #endif // _LIBCPP___MEMORY_CONCEPTS_H
64