31#ifndef ETL_FUNCTION_TRAITS_INCLUDED
32#define ETL_FUNCTION_TRAITS_INCLUDED
45 template <
typename T,
typename Enable =
void>
46 struct function_traits;
51 template <
typename TReturn,
typename... TArgs>
52 struct function_traits<TReturn(TArgs...), void>
56 using function_type = TReturn(TArgs...);
57 using return_type = TReturn;
58 using object_type = void;
59 using argument_types = etl::type_list<TArgs...>;
61 static constexpr bool is_function =
true;
62 static constexpr bool is_member_function =
false;
63 static constexpr bool is_functor =
false;
64 static constexpr bool is_const =
false;
65 static constexpr bool is_volatile =
false;
66 static constexpr bool is_noexcept =
false;
67 static constexpr size_t arity =
sizeof...(TArgs);
69 ETL_DEPRECATED_REASON(
"Use etl::function_traits::arity instead")
70 static constexpr
size_t argument_count = arity;
76 template <typename TReturn, typename... TArgs>
77 struct function_traits<TReturn(*)(TArgs...),
void> : function_traits<TReturn(TArgs...)> {};
82 template <
typename TReturn,
typename... TArgs>
83 struct function_traits<TReturn(&)(TArgs...),
void> : function_traits<TReturn(TArgs...)> {};
85#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
89 template <
typename TReturn,
typename... TArgs>
90 struct function_traits<TReturn(*)(TArgs...) noexcept,
void> : function_traits<TReturn(TArgs...)>
92 static constexpr bool is_noexcept =
true;
98 template <
typename TReturn,
typename... TArgs>
99 struct function_traits<TReturn(&)(TArgs...)
noexcept,
void> : function_traits<TReturn(TArgs...)>
101 static constexpr bool is_noexcept =
true;
108 template <
typename TReturn,
typename TObject,
typename... TArgs>
109 struct function_traits<TReturn (TObject::*)(TArgs...), void> : function_traits<TReturn(TArgs...)>
111 using object_type = TObject;
112 static constexpr bool is_function =
false;
113 static constexpr bool is_member_function =
true;
119 template <
typename TReturn,
typename TObject,
typename... TArgs>
120 struct function_traits<TReturn (TObject::*)(TArgs...) const, void> : function_traits<TReturn(TObject::*)(TArgs...)>
122 static constexpr bool is_const =
true;
128 template <
typename TReturn,
typename TObject,
typename... TArgs>
129 struct function_traits<TReturn (TObject::*)(TArgs...) volatile, void> : function_traits<TReturn(TObject::*)(TArgs...)>
131 static constexpr bool is_volatile =
true;
137 template <
typename TReturn,
typename TObject,
typename... TArgs>
138 struct function_traits<TReturn (TObject::*)(TArgs...) const volatile, void> : function_traits<TReturn(TObject::*)(TArgs...)>
140 static constexpr bool is_const =
true;
141 static constexpr bool is_volatile =
true;
144#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
148 template <
typename TReturn,
typename TObject,
typename... TArgs>
149 struct function_traits<TReturn (TObject::*)(TArgs...) noexcept, void> : function_traits<TReturn(TObject::*)(TArgs...)>
151 static constexpr bool is_noexcept =
true;
157 template <
typename TReturn,
typename TObject,
typename... TArgs>
158 struct function_traits<TReturn (TObject::*)(TArgs...) const noexcept, void> : function_traits<TReturn(TObject::*)(TArgs...) const>
160 static constexpr bool is_noexcept =
true;
166 template <
typename TReturn,
typename TObject,
typename... TArgs>
167 struct function_traits<TReturn (TObject::*)(TArgs...) volatile noexcept, void> : function_traits<TReturn(TObject::*)(TArgs...) volatile>
169 static constexpr bool is_noexcept =
true;
175 template <
typename TReturn,
typename TObject,
typename... TArgs>
176 struct function_traits<TReturn (TObject::*)(TArgs...) const volatile noexcept, void> : function_traits<TReturn(TObject::*)(TArgs...) const volatile>
178 static constexpr bool is_noexcept =
true;
185 template <
typename T>
186 struct function_traits<T, etl::enable_if_t<!etl::is_same<T, etl::remove_cvref_t<T>>::value &&
187 !etl::is_class<etl::decay_t<T>>::value>>
188 : function_traits<etl::remove_cvref_t<T>>
195 namespace private_function_traits
200 template <
typename U>
201 using call_operator_ptr_t =
decltype(&U::operator());
207 template <
typename T>
208 struct function_traits<T, etl::enable_if_t<etl::is_class<etl::decay_t<T>>::value&&
209 etl::has_unique_call_operator<T>::value>>
210 : function_traits<private_function_traits::call_operator_ptr_t<etl::decay_t<T>> >
212 static constexpr bool is_functor =
true;
219 template <
typename TReturn,
typename... TArgs>
220 constexpr bool function_traits<TReturn(TArgs...),
void>::is_function;
222 template <
typename TReturn,
typename... TArgs>
223 constexpr bool function_traits<TReturn(TArgs...),
void>::is_member_function;
225 template <
typename TReturn,
typename... TArgs>
226 constexpr bool function_traits<TReturn(TArgs...),
void>::is_functor;
228 template <
typename TReturn,
typename... TArgs>
229 constexpr bool function_traits<TReturn(TArgs...),
void>::is_const;
231 template <
typename TReturn,
typename... TArgs>
232 constexpr bool function_traits<TReturn(TArgs...),
void>::is_volatile;
234 template <
typename TReturn,
typename... TArgs>
235 constexpr bool function_traits<TReturn(TArgs...),
void>::is_noexcept;
237 template <
typename TReturn,
typename... TArgs>
238 constexpr size_t function_traits<TReturn(TArgs...),
void>::arity;
241 template <
typename TReturn,
typename TObject,
typename... TArgs>
242 constexpr bool function_traits<TReturn (TObject::*)(TArgs...),
void>::is_function;
244 template <
typename TReturn,
typename TObject,
typename... TArgs>
245 constexpr bool function_traits<TReturn (TObject::*)(TArgs...),
void>::is_member_function;
248 template <
typename TReturn,
typename TObject,
typename... TArgs>
249 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
const,
void>::is_const;
251 template <
typename TReturn,
typename TObject,
typename... TArgs>
252 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
volatile,
void>::is_volatile;
254 template <
typename TReturn,
typename TObject,
typename... TArgs>
255 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
const volatile,
void>::is_const;
257 template <
typename TReturn,
typename TObject,
typename... TArgs>
258 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
const volatile,
void>::is_volatile;
260#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
261 template <
typename TReturn,
typename... TArgs>
262 constexpr bool function_traits<TReturn(*)(TArgs...)
noexcept,
void>::is_noexcept;
264 template <
typename TReturn,
typename TObject,
typename... TArgs>
265 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
noexcept,
void>::is_noexcept;
267 template <
typename TReturn,
typename TObject,
typename... TArgs>
268 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
const noexcept,
void>::is_noexcept;
270 template <
typename TReturn,
typename TObject,
typename... TArgs>
271 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
volatile noexcept,
void>::is_noexcept;
273 template <
typename TReturn,
typename TObject,
typename... TArgs>
274 constexpr bool function_traits<TReturn (TObject::*)(TArgs...)
const volatile noexcept,
void>::is_noexcept;
280 template <
typename T>
281 constexpr bool function_traits<T, etl::enable_if_t<etl::is_class<etl::decay_t<T>>::value &&
282 etl::has_unique_call_operator<T>::value>>::is_functor;
bitset_ext
Definition absolute.h:39