xref: /freebsd-src/contrib/llvm-project/libcxx/include/__tuple/tuple_like_no_subrange.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
2*0fca6ea1SDimitry Andric //
3*0fca6ea1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0fca6ea1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0fca6ea1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0fca6ea1SDimitry Andric //
7*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
8*0fca6ea1SDimitry Andric 
9*0fca6ea1SDimitry Andric #ifndef _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
10*0fca6ea1SDimitry Andric #define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
11*0fca6ea1SDimitry Andric 
12*0fca6ea1SDimitry Andric #include <__config>
13*0fca6ea1SDimitry Andric #include <__fwd/array.h>
14*0fca6ea1SDimitry Andric #include <__fwd/complex.h>
15*0fca6ea1SDimitry Andric #include <__fwd/pair.h>
16*0fca6ea1SDimitry Andric #include <__fwd/tuple.h>
17*0fca6ea1SDimitry Andric #include <__tuple/tuple_size.h>
18*0fca6ea1SDimitry Andric #include <__type_traits/remove_cvref.h>
19*0fca6ea1SDimitry Andric #include <cstddef>
20*0fca6ea1SDimitry Andric 
21*0fca6ea1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22*0fca6ea1SDimitry Andric #  pragma GCC system_header
23*0fca6ea1SDimitry Andric #endif
24*0fca6ea1SDimitry Andric 
25*0fca6ea1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
26*0fca6ea1SDimitry Andric 
27*0fca6ea1SDimitry Andric #if _LIBCPP_STD_VER >= 20
28*0fca6ea1SDimitry Andric 
29*0fca6ea1SDimitry Andric template <class _Tp>
30*0fca6ea1SDimitry Andric inline constexpr bool __tuple_like_no_subrange_impl = false;
31*0fca6ea1SDimitry Andric 
32*0fca6ea1SDimitry Andric template <class... _Tp>
33*0fca6ea1SDimitry Andric inline constexpr bool __tuple_like_no_subrange_impl<tuple<_Tp...>> = true;
34*0fca6ea1SDimitry Andric 
35*0fca6ea1SDimitry Andric template <class _T1, class _T2>
36*0fca6ea1SDimitry Andric inline constexpr bool __tuple_like_no_subrange_impl<pair<_T1, _T2>> = true;
37*0fca6ea1SDimitry Andric 
38*0fca6ea1SDimitry Andric template <class _Tp, size_t _Size>
39*0fca6ea1SDimitry Andric inline constexpr bool __tuple_like_no_subrange_impl<array<_Tp, _Size>> = true;
40*0fca6ea1SDimitry Andric 
41*0fca6ea1SDimitry Andric #  if _LIBCPP_STD_VER >= 26
42*0fca6ea1SDimitry Andric 
43*0fca6ea1SDimitry Andric template <class _Tp>
44*0fca6ea1SDimitry Andric inline constexpr bool __tuple_like_no_subrange_impl<complex<_Tp>> = true;
45*0fca6ea1SDimitry Andric 
46*0fca6ea1SDimitry Andric #  endif
47*0fca6ea1SDimitry Andric 
48*0fca6ea1SDimitry Andric template <class _Tp>
49*0fca6ea1SDimitry Andric concept __tuple_like_no_subrange = __tuple_like_no_subrange_impl<remove_cvref_t<_Tp>>;
50*0fca6ea1SDimitry Andric 
51*0fca6ea1SDimitry Andric // This is equivalent to the exposition-only type trait `pair-like`, except that it is false for specializations of
52*0fca6ea1SDimitry Andric // `ranges::subrange`. This is more useful than the pair-like concept in the standard because every use of `pair-like`
53*0fca6ea1SDimitry Andric // excludes `ranges::subrange`.
54*0fca6ea1SDimitry Andric template <class _Tp>
55*0fca6ea1SDimitry Andric concept __pair_like_no_subrange = __tuple_like_no_subrange<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2;
56*0fca6ea1SDimitry Andric 
57*0fca6ea1SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
58*0fca6ea1SDimitry Andric 
59*0fca6ea1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
60*0fca6ea1SDimitry Andric 
61*0fca6ea1SDimitry Andric #endif // _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
62