blob: ec1fab4602d7f60a37dc57040aa9ddc4e9ba7b37 [file] [log] [blame]
Stephen Hinesc6ca60f2023-05-09 02:19:22 -07001//===----------------------------------------------------------------------===//
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
9#ifndef _LIBCPP___FWD_GET_H
10#define _LIBCPP___FWD_GET_H
11
12#include <__concepts/copyable.h>
13#include <__config>
14#include <__fwd/array.h>
15#include <__fwd/pair.h>
16#include <__fwd/subrange.h>
17#include <__fwd/tuple.h>
18#include <__tuple_dir/tuple_element.h>
19#include <cstddef>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#ifndef _LIBCPP_CXX03_LANG
28
29template <size_t _Ip, class ..._Tp>
30_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
31typename tuple_element<_Ip, tuple<_Tp...> >::type&
32get(tuple<_Tp...>&) _NOEXCEPT;
33
34template <size_t _Ip, class ..._Tp>
35_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
36const typename tuple_element<_Ip, tuple<_Tp...> >::type&
37get(const tuple<_Tp...>&) _NOEXCEPT;
38
39template <size_t _Ip, class ..._Tp>
40_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
41typename tuple_element<_Ip, tuple<_Tp...> >::type&&
42get(tuple<_Tp...>&&) _NOEXCEPT;
43
44template <size_t _Ip, class ..._Tp>
45_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
46const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
47get(const tuple<_Tp...>&&) _NOEXCEPT;
48
49#endif //_LIBCPP_CXX03_LANG
50
51template <size_t _Ip, class _T1, class _T2>
52_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
53typename tuple_element<_Ip, pair<_T1, _T2> >::type&
54get(pair<_T1, _T2>&) _NOEXCEPT;
55
56template <size_t _Ip, class _T1, class _T2>
57_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
58const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
59get(const pair<_T1, _T2>&) _NOEXCEPT;
60
61#ifndef _LIBCPP_CXX03_LANG
62template <size_t _Ip, class _T1, class _T2>
63_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
64typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
65get(pair<_T1, _T2>&&) _NOEXCEPT;
66
67template <size_t _Ip, class _T1, class _T2>
68_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
69const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
70get(const pair<_T1, _T2>&&) _NOEXCEPT;
71#endif
72
73template <size_t _Ip, class _Tp, size_t _Size>
74_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
75_Tp&
76get(array<_Tp, _Size>&) _NOEXCEPT;
77
78template <size_t _Ip, class _Tp, size_t _Size>
79_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
80const _Tp&
81get(const array<_Tp, _Size>&) _NOEXCEPT;
82
83#ifndef _LIBCPP_CXX03_LANG
84template <size_t _Ip, class _Tp, size_t _Size>
85_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
86_Tp&&
87get(array<_Tp, _Size>&&) _NOEXCEPT;
88
89template <size_t _Ip, class _Tp, size_t _Size>
90_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
91const _Tp&&
92get(const array<_Tp, _Size>&&) _NOEXCEPT;
93#endif
94
95#if _LIBCPP_STD_VER >= 20
96
97namespace ranges {
98
99template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
100 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
101_LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange);
102
103template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
104 requires(_Index < 2)
105_LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange);
106
107} // namespace ranges
108
109using ranges::get;
110
111#endif // _LIBCPP_STD_VER >= 20
112
113_LIBCPP_END_NAMESPACE_STD
114
115#endif // _LIBCPP___FWD_GET_H