能否计算出lambda的参数类型和返回类型?
lambda_traits
auto lambda = [](int i) { return long(i*10); };lambda_traits<decltype(lambda)>::param_type i; //i should be intlambda_traits<decltype(lambda)>::return_type l; //l should be long
lambda_traits
template<typename TLambda>void f(TLambda lambda){ typedef typename lambda_traits<TLambda>::param_type P; typedef typename lambda_traits<TLambda>::return_type R; std::function<R(P)> fun = lambda; //I want to do this! //...}
std::function
template<typename T>A<T> f(std::function<bool(T)> fun){ return A<T>(fun);}f([](int){return true;}); //error
TLambda
std::function
守着一只汪
动漫人物
相关分类