tuple_like.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef _LIBCPP___TUPLE_TUPLE_LIKE_H
  9. #define _LIBCPP___TUPLE_TUPLE_LIKE_H
  10. #include <__config>
  11. #include <__fwd/array.h>
  12. #include <__fwd/complex.h>
  13. #include <__fwd/pair.h>
  14. #include <__fwd/subrange.h>
  15. #include <__fwd/tuple.h>
  16. #include <__type_traits/integral_constant.h>
  17. #include <__type_traits/remove_cvref.h>
  18. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  19. # pragma GCC system_header
  20. #endif
  21. _LIBCPP_BEGIN_NAMESPACE_STD
  22. #if _LIBCPP_STD_VER >= 20
  23. template <class _Tp>
  24. struct __tuple_like_impl : false_type {};
  25. template <class... _Tp>
  26. struct __tuple_like_impl<tuple<_Tp...> > : true_type {};
  27. template <class _T1, class _T2>
  28. struct __tuple_like_impl<pair<_T1, _T2> > : true_type {};
  29. template <class _Tp, size_t _Size>
  30. struct __tuple_like_impl<array<_Tp, _Size> > : true_type {};
  31. template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
  32. struct __tuple_like_impl<ranges::subrange<_Ip, _Sp, _Kp> > : true_type {};
  33. # if _LIBCPP_STD_VER >= 26
  34. template <class _Tp>
  35. struct __tuple_like_impl<complex<_Tp>> : true_type {};
  36. # endif
  37. template <class _Tp>
  38. concept __tuple_like = __tuple_like_impl<remove_cvref_t<_Tp>>::value;
  39. #endif // _LIBCPP_STD_VER >= 20
  40. _LIBCPP_END_NAMESPACE_STD
  41. #endif // _LIBCPP___TUPLE_TUPLE_LIKE_H