| 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 |
|
| 23 |
template <size_t _Ip, class _Tp> |
| 24 |
struct _LIBCPP_TEMPLATE_VIS tuple_element; |
| 25 |
|
| 26 |
template <size_t _Ip, class _Tp> |
| 27 |
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> { |
| 28 |
typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type; |
| 29 |
}; |
| 30 |
|
| 31 |
template <size_t _Ip, class _Tp> |
| 32 |
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> { |
| 33 |
typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type; |
| 34 |
}; |
| 35 |
|
| 36 |
template <size_t _Ip, class _Tp> |
| 37 |
struct _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 |
|
| 43 |
template <size_t _Ip, class... _Types> |
| 44 |
struct _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 |
| 50 |
template <size_t _Ip, class... _Tp> |
| 51 |
using 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 |