Friday, October 16, 2015

Signature for C++ lambda function

Lambda function is a class with operator()(...) const. This class does not have default constructor or copy constructor.

Hence the function signature of a lambda function f can be accessed as the following:

 template<typename F> class traits;  
 template<typename C, typename R, typename... Args> struct traits<R (C::*)(Args...) const> {  
   typedef R result_type;  
 typedef typename traits<decltype(&decltype(lambda)::operator())>::result_type result_type;