File indexing completed on 2026-05-03 08:13:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___TUPLE_FIND_INDEX_H
0010 #define _LIBCPP___CXX03___TUPLE_FIND_INDEX_H
0011
0012 #include <__cxx03/__config>
0013 #include <__cxx03/__type_traits/is_same.h>
0014 #include <__cxx03/cstddef>
0015
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 # pragma GCC system_header
0018 #endif
0019
0020 #if _LIBCPP_STD_VER >= 14
0021
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023
0024 namespace __find_detail {
0025
0026 static constexpr size_t __not_found = static_cast<size_t>(-1);
0027 static constexpr size_t __ambiguous = __not_found - 1;
0028
0029 inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
0030 return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous);
0031 }
0032
0033 template <size_t _Nx>
0034 inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
0035 return __i == _Nx
0036 ? __not_found
0037 : __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
0038 }
0039
0040 template <class _T1, class... _Args>
0041 struct __find_exactly_one_checked {
0042 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
0043 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
0044 static_assert(value != __not_found, "type not found in type list");
0045 static_assert(value != __ambiguous, "type occurs more than once in type list");
0046 };
0047
0048 template <class _T1>
0049 struct __find_exactly_one_checked<_T1> {
0050 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
0051 };
0052
0053 }
0054
0055 template <typename _T1, typename... _Args>
0056 struct __find_exactly_one_t : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {};
0057
0058 _LIBCPP_END_NAMESPACE_STD
0059
0060 #endif
0061
0062 #endif