how to correctly find out the return type of a lambda

后端 未结 3 1901
闹比i
闹比i 2020-12-11 22:04

basically how to make following code compile?

I know it failed because compiler was trying to evaluate something like ([](int &i){})(0) but how to s

3条回答
  •  鱼传尺愫
    2020-12-11 22:41

    You may use following traits:

    template 
    struct return_type : return_type
    {};
    // For generic types, directly use the result of the signature of its 'operator()'
    
    template 
    struct return_type
    {
        using type = ReturnType;
    };
    

提交回复
热议问题