concepts.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  21. # pragma GCC system_header
  22. #endif
  23. _LIBCPP_BEGIN_NAMESPACE_STD
  24. #if _LIBCPP_STD_VER > 17
  25. namespace ranges {
  26. // [special.mem.concepts]
  27. // This concept ensures that uninitialized algorithms can construct an object
  28. // at the address pointed-to by the iterator, which requires an lvalue.
  29. template <class _Ip>
  30. concept __nothrow_input_iterator =
  31. input_iterator<_Ip> &&
  32. is_lvalue_reference_v<iter_reference_t<_Ip>> &&
  33. same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>;
  34. template <class _Sp, class _Ip>
  35. concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
  36. template <class _Rp>
  37. concept __nothrow_input_range =
  38. range<_Rp> &&
  39. __nothrow_input_iterator<iterator_t<_Rp>> &&
  40. __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>;
  41. template <class _Ip>
  42. concept __nothrow_forward_iterator =
  43. __nothrow_input_iterator<_Ip> &&
  44. forward_iterator<_Ip> &&
  45. __nothrow_sentinel_for<_Ip, _Ip>;
  46. template <class _Rp>
  47. concept __nothrow_forward_range =
  48. __nothrow_input_range<_Rp> &&
  49. __nothrow_forward_iterator<iterator_t<_Rp>>;
  50. } // namespace ranges
  51. #endif // _LIBCPP_STD_VER > 17
  52. _LIBCPP_END_NAMESPACE_STD
  53. #endif // _LIBCPP___MEMORY_CONCEPTS_H