[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / libcxx / include / __tuple / sfinae_helpers.h
blob9041d1d4473e86f0369b07a1ffd73322930f5ea3
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 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___TUPLE_SFINAE_HELPERS_H
10 #define _LIBCPP___TUPLE_SFINAE_HELPERS_H
12 #include <__config>
13 #include <__cstddef/size_t.h>
14 #include <__fwd/tuple.h>
15 #include <__tuple/make_tuple_types.h>
16 #include <__tuple/tuple_element.h>
17 #include <__tuple/tuple_like_ext.h>
18 #include <__tuple/tuple_size.h>
19 #include <__tuple/tuple_types.h>
20 #include <__type_traits/conjunction.h>
21 #include <__type_traits/enable_if.h>
22 #include <__type_traits/integral_constant.h>
23 #include <__type_traits/is_constructible.h>
24 #include <__type_traits/is_same.h>
25 #include <__type_traits/remove_cvref.h>
26 #include <__type_traits/remove_reference.h>
28 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29 # pragma GCC system_header
30 #endif
32 _LIBCPP_BEGIN_NAMESPACE_STD
34 #ifndef _LIBCPP_CXX03_LANG
36 struct __tuple_sfinae_base {
37 template <template <class, class...> class _Trait, class... _LArgs, class... _RArgs>
38 static auto __do_test(__tuple_types<_LArgs...>,
39 __tuple_types<_RArgs...>) -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
40 template <template <class...> class>
41 static auto __do_test(...) -> false_type;
43 template <class _FromArgs, class _ToArgs>
44 using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
47 // __tuple_constructible
49 template <class _Tp,
50 class _Up,
51 bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
52 bool = __tuple_like_ext<_Up>::value>
53 struct __tuple_constructible : public false_type {};
55 template <class _Tp, class _Up>
56 struct __tuple_constructible<_Tp, _Up, true, true>
57 : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type,
58 typename __make_tuple_types<_Up>::type > {};
60 template <size_t _Ip, class... _Tp>
61 struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {
62 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type;
65 struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail {
66 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() { return false; }
67 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { return false; }
68 template <class...>
69 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit() {
70 return false;
72 template <class...>
73 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit() {
74 return false;
76 template <class...>
77 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_assign() {
78 return false;
81 #endif // !defined(_LIBCPP_CXX03_LANG)
83 #if _LIBCPP_STD_VER >= 17
85 template <bool _CanCopy, bool _CanMove>
86 struct __sfinae_ctor_base {};
87 template <>
88 struct __sfinae_ctor_base<false, false> {
89 __sfinae_ctor_base() = default;
90 __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
91 __sfinae_ctor_base(__sfinae_ctor_base&&) = delete;
92 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
93 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
95 template <>
96 struct __sfinae_ctor_base<true, false> {
97 __sfinae_ctor_base() = default;
98 __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
99 __sfinae_ctor_base(__sfinae_ctor_base&&) = delete;
100 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
101 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
103 template <>
104 struct __sfinae_ctor_base<false, true> {
105 __sfinae_ctor_base() = default;
106 __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
107 __sfinae_ctor_base(__sfinae_ctor_base&&) = default;
108 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
109 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
112 template <bool _CanCopy, bool _CanMove>
113 struct __sfinae_assign_base {};
114 template <>
115 struct __sfinae_assign_base<false, false> {
116 __sfinae_assign_base() = default;
117 __sfinae_assign_base(__sfinae_assign_base const&) = default;
118 __sfinae_assign_base(__sfinae_assign_base&&) = default;
119 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
120 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
122 template <>
123 struct __sfinae_assign_base<true, false> {
124 __sfinae_assign_base() = default;
125 __sfinae_assign_base(__sfinae_assign_base const&) = default;
126 __sfinae_assign_base(__sfinae_assign_base&&) = default;
127 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
128 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
130 template <>
131 struct __sfinae_assign_base<false, true> {
132 __sfinae_assign_base() = default;
133 __sfinae_assign_base(__sfinae_assign_base const&) = default;
134 __sfinae_assign_base(__sfinae_assign_base&&) = default;
135 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
136 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
138 #endif // _LIBCPP_STD_VER >= 17
140 _LIBCPP_END_NAMESPACE_STD
142 #endif // _LIBCPP___TUPLE_SFINAE_HELPERS_H