concepts.h 2.0 KB

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