* setter implementation has defined wrong types
* is_valid did never evaluate to false_t
master
| @@ -17,7 +17,7 @@ namespace cppmp | |||||
| /** | /** | ||||
| * @brief Evaluates to true_t if the passed template parameters are valid, false_t otherwise. | * @brief Evaluates to true_t if the passed template parameters are valid, false_t otherwise. | ||||
| */ | */ | ||||
| template<typename...> | |||||
| template<typename T, typename = void> | |||||
| struct is_valid; | struct is_valid; | ||||
| /** | /** | ||||
| @@ -29,8 +29,18 @@ namespace cppmp | |||||
| /* is_valid */ | /* is_valid */ | ||||
| template<typename...> | |||||
| template<typename T, typename> | |||||
| struct is_valid | struct is_valid | ||||
| : public false_t | |||||
| { }; | |||||
| template<typename T> | |||||
| struct is_valid<T, void_t<decltype(sizeof(T))>> | |||||
| : public true_t | |||||
| { }; | |||||
| template<> | |||||
| struct is_valid<void, void> | |||||
| : public true_t | : public true_t | ||||
| { }; | { }; | ||||
| @@ -140,8 +140,8 @@ namespace cppmp | |||||
| { | { | ||||
| using lambda_type = T_lambda; | using lambda_type = T_lambda; | ||||
| using lambda_traits_type = lambda_traits<lambda_type>; | using lambda_traits_type = lambda_traits<lambda_type>; | ||||
| using object_type = typename lambda_traits_type::template argument_t<0>; | |||||
| using value_type = typename lambda_traits_type::return_type; | |||||
| using object_type = decay_t<typename lambda_traits_type::template argument_t<0>>; | |||||
| using value_type = decay_t<typename lambda_traits_type::template argument_t<1>>; | |||||
| lambda_type lambda; | lambda_type lambda; | ||||
| @@ -62,52 +62,3 @@ namespace cppmp | |||||
| { }; | { }; | ||||
| } | } | ||||
| #pragma once | |||||
| #include <tuple> | |||||
| #include <type_traits> | |||||
| namespace stx | |||||
| { | |||||
| namespace lambda_detail | |||||
| { | |||||
| template<class Ret, class Cls, class IsMutable, class... Args> | |||||
| struct types | |||||
| { | |||||
| using is_mutable = IsMutable; | |||||
| enum { arity = sizeof...(Args) }; | |||||
| using return_type = Ret; | |||||
| template<size_t i> | |||||
| struct arg | |||||
| { | |||||
| typedef typename std::tuple_element<i, std::tuple<Args...>>::type type; | |||||
| }; | |||||
| }; | |||||
| } | |||||
| template<class Ld> | |||||
| struct lambda_type | |||||
| : lambda_type<decltype(&Ld::operator())> | |||||
| {}; | |||||
| template<class Ret, class Cls, class... Args> | |||||
| struct lambda_type<Ret(Cls::*)(Args...)> | |||||
| : lambda_detail::types<Ret,Cls,std::true_type,Args...> | |||||
| {}; | |||||
| template<class Ret, class Cls, class... Args> | |||||
| struct lambda_type<Ret(Cls::*)(Args...) const> | |||||
| : lambda_detail::types<Ret,Cls,std::false_type,Args...> | |||||
| {}; | |||||
| }; | |||||