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
9#ifndef _LIBCPP___TUPLE_TUPLE_ELEMENT_H
10#define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
11
12#include <__config>
13#include <__tuple/tuple_indices.h>
14#include <__tuple/tuple_types.h>
15#include <cstddef>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <size_t _Ip, class _Tp>
24struct _LIBCPP_TEMPLATE_VIS tuple_element;
25
26template <size_t _Ip, class _Tp>
27struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {
28 typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type;
29};
30
31template <size_t _Ip, class _Tp>
32struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {
33 typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type;
34};
35
36template <size_t _Ip, class _Tp>
37struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {
38 typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type;
39};
40
41#ifndef _LIBCPP_CXX03_LANG
42
43template <size_t _Ip, class... _Types>
44struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {
45 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
46 typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
47};
48
49# if _LIBCPP_STD_VER >= 14
50template <size_t _Ip, class... _Tp>
51using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element<_Ip, _Tp...>::type;
52# endif
53
54#endif // _LIBCPP_CXX03_LANG
55
56_LIBCPP_END_NAMESPACE_STD
57
58#endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H
59