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_SIZE_H 10 #define _LIBCPP___TUPLE_TUPLE_SIZE_H 11 12 #include <__config> 13 #include <__fwd/tuple.h> 14 #include <__tuple/tuple_types.h> 15 #include <__type_traits/is_const.h> 16 #include <__type_traits/is_volatile.h> 17 #include <cstddef> 18 19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 20 # pragma GCC system_header 21 #endif 22 23 _LIBCPP_BEGIN_NAMESPACE_STD 24 25 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size; 26 27 #if !defined(_LIBCPP_CXX03_LANG) 28 template <class _Tp, class...> 29 using __enable_if_tuple_size_imp = _Tp; 30 31 template <class _Tp> 32 struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< 33 const _Tp, 34 __enable_if_t<!is_volatile<_Tp>::value>, 35 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> 36 : public integral_constant<size_t, tuple_size<_Tp>::value> {}; 37 38 template <class _Tp> 39 struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< 40 volatile _Tp, 41 __enable_if_t<!is_const<_Tp>::value>, 42 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> 43 : public integral_constant<size_t, tuple_size<_Tp>::value> {}; 44 45 template <class _Tp> 46 struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< 47 const volatile _Tp, 48 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> 49 : public integral_constant<size_t, tuple_size<_Tp>::value> {}; 50 51 #else 52 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {}; 53 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {}; 54 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; 55 #endif 56 57 #ifndef _LIBCPP_CXX03_LANG 58 59 template <class ..._Tp> 60 struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > 61 : public integral_constant<size_t, sizeof...(_Tp)> 62 { 63 }; 64 65 template <class ..._Tp> 66 struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > 67 : public integral_constant<size_t, sizeof...(_Tp)> 68 { 69 }; 70 71 #endif // _LIBCPP_CXX03_LANG 72 73 _LIBCPP_END_NAMESPACE_STD 74 75 #endif // _LIBCPP___TUPLE_TUPLE_SIZE_H 76