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