get.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef _LIBCPP___FWD_GET_H
  9. #define _LIBCPP___FWD_GET_H
  10. #include <__concepts/copyable.h>
  11. #include <__config>
  12. #include <__fwd/array.h>
  13. #include <__fwd/pair.h>
  14. #include <__fwd/subrange.h>
  15. #include <__fwd/tuple.h>
  16. #include <__tuple_dir/tuple_element.h>
  17. #include <cstddef>
  18. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  19. # pragma GCC system_header
  20. #endif
  21. _LIBCPP_BEGIN_NAMESPACE_STD
  22. #ifndef _LIBCPP_CXX03_LANG
  23. template <size_t _Ip, class ..._Tp>
  24. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  25. typename tuple_element<_Ip, tuple<_Tp...> >::type&
  26. get(tuple<_Tp...>&) _NOEXCEPT;
  27. template <size_t _Ip, class ..._Tp>
  28. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  29. const typename tuple_element<_Ip, tuple<_Tp...> >::type&
  30. get(const tuple<_Tp...>&) _NOEXCEPT;
  31. template <size_t _Ip, class ..._Tp>
  32. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  33. typename tuple_element<_Ip, tuple<_Tp...> >::type&&
  34. get(tuple<_Tp...>&&) _NOEXCEPT;
  35. template <size_t _Ip, class ..._Tp>
  36. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  37. const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
  38. get(const tuple<_Tp...>&&) _NOEXCEPT;
  39. #endif //_LIBCPP_CXX03_LANG
  40. template <size_t _Ip, class _T1, class _T2>
  41. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  42. typename tuple_element<_Ip, pair<_T1, _T2> >::type&
  43. get(pair<_T1, _T2>&) _NOEXCEPT;
  44. template <size_t _Ip, class _T1, class _T2>
  45. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  46. const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
  47. get(const pair<_T1, _T2>&) _NOEXCEPT;
  48. #ifndef _LIBCPP_CXX03_LANG
  49. template <size_t _Ip, class _T1, class _T2>
  50. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  51. typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
  52. get(pair<_T1, _T2>&&) _NOEXCEPT;
  53. template <size_t _Ip, class _T1, class _T2>
  54. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  55. const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
  56. get(const pair<_T1, _T2>&&) _NOEXCEPT;
  57. #endif
  58. template <size_t _Ip, class _Tp, size_t _Size>
  59. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  60. _Tp&
  61. get(array<_Tp, _Size>&) _NOEXCEPT;
  62. template <size_t _Ip, class _Tp, size_t _Size>
  63. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  64. const _Tp&
  65. get(const array<_Tp, _Size>&) _NOEXCEPT;
  66. #ifndef _LIBCPP_CXX03_LANG
  67. template <size_t _Ip, class _Tp, size_t _Size>
  68. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  69. _Tp&&
  70. get(array<_Tp, _Size>&&) _NOEXCEPT;
  71. template <size_t _Ip, class _Tp, size_t _Size>
  72. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
  73. const _Tp&&
  74. get(const array<_Tp, _Size>&&) _NOEXCEPT;
  75. #endif
  76. #if _LIBCPP_STD_VER >= 20
  77. namespace ranges {
  78. template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
  79. requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
  80. _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange);
  81. template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
  82. requires(_Index < 2)
  83. _LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange);
  84. } // namespace ranges
  85. using ranges::get;
  86. #endif // _LIBCPP_STD_VER >= 20
  87. _LIBCPP_END_NAMESPACE_STD
  88. #endif // _LIBCPP___FWD_GET_H