solve problem with adc_func_traits
add and use concept adc_is_callable rewrite value holder and device attribute classes with new constructor's arguments resolution scheme
This commit is contained in:
@@ -67,10 +67,16 @@ struct adc_func_traits_helper_t<R, Arg, Args...> {
|
||||
};
|
||||
|
||||
|
||||
// callable traits
|
||||
// callable concept and its signature traits
|
||||
|
||||
template <typename F, typename = void>
|
||||
struct adc_func_traits;
|
||||
template <typename T>
|
||||
concept adc_is_callable =
|
||||
std::is_function_v<T> || (std::is_object_v<T> && requires(T) { std::is_function_v<decltype(&T::operator())>; });
|
||||
|
||||
template <typename F>
|
||||
struct adc_func_traits {
|
||||
// use of an empty struct here to match std::invoke_result behaivior (at least of GCC)
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct adc_func_traits<R (*)(Args...)> : adc_func_traits_helper_t<R, Args...> {
|
||||
@@ -89,8 +95,8 @@ struct adc_func_traits<R (C::*)(Args...) const> : adc_func_traits_helper_t<R, Ar
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
// struct adc_func_traits : adc_func_traits<decltype(&std::remove_reference_t<F>::operator())> {
|
||||
struct adc_func_traits<F, std::enable_if_t<std::is_class_v<F>>> : adc_func_traits<decltype(&F::operator())> {
|
||||
requires adc_is_callable<F>
|
||||
struct adc_func_traits<F> : adc_func_traits<decltype(&F::operator())> {
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
@@ -138,13 +144,32 @@ template <typename T>
|
||||
struct adc_is_tuple : std::false_type {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct adc_is_tuple<T&> : adc_is_tuple<T> {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct adc_is_tuple<const T&> : adc_is_tuple<T> {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct adc_is_tuple<T&&> : adc_is_tuple<T> {
|
||||
};
|
||||
|
||||
|
||||
template <typename... Ts>
|
||||
struct adc_is_tuple<std::tuple<Ts...>> : std::true_type {
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct adc_is_tuple<std::pair<T1, T2>> : std::true_type {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static inline constexpr bool adc_is_tuple_v = adc_is_tuple<T>::value;
|
||||
|
||||
template <typename T>
|
||||
concept adc_tuple_like = adc_is_tuple_v<T> == true;
|
||||
|
||||
|
||||
} // namespace adc::traits
|
||||
|
||||
Reference in New Issue
Block a user