concepts.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___MEMORY_CONCEPTS_H
  10. #define _LIBCPP___MEMORY_CONCEPTS_H
  11. #include <__concepts/same_as.h>
  12. #include <__config>
  13. #include <__iterator/concepts.h>
  14. #include <__iterator/iterator_traits.h>
  15. #include <__iterator/readable_traits.h>
  16. #include <__ranges/access.h>
  17. #include <__ranges/concepts.h>
  18. #include <__type_traits/is_reference.h>
  19. #include <__type_traits/remove_cvref.h>
  20. #include <__type_traits/remove_reference.h> // TODO(modules): This should not be required
  21. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  22. # pragma GCC system_header
  23. #endif
  24. _LIBCPP_BEGIN_NAMESPACE_STD
  25. #if _LIBCPP_STD_VER >= 20
  26. namespace ranges {
  27. // [special.mem.concepts]
  28. // This concept ensures that uninitialized algorithms can construct an object
  29. // at the address pointed-to by the iterator, which requires an lvalue.
  30. template <class _Ip>
  31. concept __nothrow_input_iterator =
  32. input_iterator<_Ip> &&
  33. is_lvalue_reference_v<iter_reference_t<_Ip>> &&
  34. same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
  35. template <class _Sp, class _Ip>
  36. concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
  37. template <class _Rp>
  38. concept __nothrow_input_range =
  39. range<_Rp> &&
  40. __nothrow_input_iterator<iterator_t<_Rp>> &&
  41. __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
  42. template <class _Ip>
  43. concept __nothrow_forward_iterator =
  44. __nothrow_input_iterator<_Ip> &&
  45. forward_iterator<_Ip> &&
  46. __nothrow_sentinel_for<_Ip, _Ip>;
  47. template <class _Rp>
  48. concept __nothrow_forward_range =
  49. __nothrow_input_range<_Rp> &&
  50. __nothrow_forward_iterator<iterator_t<_Rp>>;
  51. } // namespace ranges
  52. #endif // _LIBCPP_STD_VER >= 20
  53. _LIBCPP_END_NAMESPACE_STD
  54. #endif // _LIBCPP___MEMORY_CONCEPTS_H