#include <iostream>
#include <type_traits>

template <typename T, typename U>
struct helper : helper<T, decltype(&U::operator())>
{};
        
template <typename T, typename C, typename R, typename... A>
struct helper<T, R(C::*)(A...) const> 
{
    static const bool value = std::is_convertible<T, R(*)(A...)>::value;
};

template<typename T>
struct is_stateless
{
    static const bool value = helper<T,T>::value;
};
        
int main() 
{
    int a;
    auto l1 = [](){ return 1; };
    auto l2 = [](){ return 2; };
    auto l3 = [&a](){ return 2; };
    
    std::cout << std::boolalpha << is_stateless<decltype(l1)>::value << "\n";
    std::cout << std::boolalpha << is_stateless<decltype(l2)>::value << "\n";
    std::cout << std::boolalpha << is_stateless<decltype(l3)>::value << "\n";
}