xref: /freebsd-src/contrib/llvm-project/libcxx/include/__tuple/tuple_element.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
106c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
206c3fb27SDimitry Andric //
306c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
406c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
506c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
606c3fb27SDimitry Andric //
706c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
806c3fb27SDimitry Andric 
906c3fb27SDimitry Andric #ifndef _LIBCPP___TUPLE_TUPLE_ELEMENT_H
1006c3fb27SDimitry Andric #define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
1106c3fb27SDimitry Andric 
1206c3fb27SDimitry Andric #include <__config>
1306c3fb27SDimitry Andric #include <__tuple/tuple_indices.h>
1406c3fb27SDimitry Andric #include <__tuple/tuple_types.h>
1506c3fb27SDimitry Andric #include <cstddef>
1606c3fb27SDimitry Andric 
1706c3fb27SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1806c3fb27SDimitry Andric #  pragma GCC system_header
1906c3fb27SDimitry Andric #endif
2006c3fb27SDimitry Andric 
2106c3fb27SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
2206c3fb27SDimitry Andric 
23cb14a3feSDimitry Andric template <size_t _Ip, class _Tp>
24cb14a3feSDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element;
2506c3fb27SDimitry Andric 
2606c3fb27SDimitry Andric template <size_t _Ip, class _Tp>
27cb14a3feSDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {
28*0fca6ea1SDimitry Andric   typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type;
2906c3fb27SDimitry Andric };
3006c3fb27SDimitry Andric 
3106c3fb27SDimitry Andric template <size_t _Ip, class _Tp>
32cb14a3feSDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {
33*0fca6ea1SDimitry Andric   typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type;
3406c3fb27SDimitry Andric };
3506c3fb27SDimitry Andric 
3606c3fb27SDimitry Andric template <size_t _Ip, class _Tp>
37cb14a3feSDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {
38*0fca6ea1SDimitry Andric   typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type;
3906c3fb27SDimitry Andric };
4006c3fb27SDimitry Andric 
4106c3fb27SDimitry Andric #ifndef _LIBCPP_CXX03_LANG
4206c3fb27SDimitry Andric 
4306c3fb27SDimitry Andric template <size_t _Ip, class... _Types>
44cb14a3feSDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {
4506c3fb27SDimitry Andric   static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
4606c3fb27SDimitry Andric   typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
4706c3fb27SDimitry Andric };
4806c3fb27SDimitry Andric 
4906c3fb27SDimitry Andric #  if _LIBCPP_STD_VER >= 14
5006c3fb27SDimitry Andric template <size_t _Ip, class... _Tp>
5106c3fb27SDimitry Andric using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element<_Ip, _Tp...>::type;
5206c3fb27SDimitry Andric #  endif
5306c3fb27SDimitry Andric 
5406c3fb27SDimitry Andric #endif // _LIBCPP_CXX03_LANG
5506c3fb27SDimitry Andric 
5606c3fb27SDimitry Andric _LIBCPP_END_NAMESPACE_STD
5706c3fb27SDimitry Andric 
5806c3fb27SDimitry Andric #endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H
59