Arity of a generic lambda

前端 未结 5 1249
说谎
说谎 2020-12-01 23:53

It is possible to deduce arity of a non-generic lambda by accessing its operator().

template 
struct fInfo : fInfo

        
5条回答
  •  遥遥无期
    2020-12-02 00:38

    Another posible solution, for case when possible template types are known: http://coliru.stacked-crooked.com/a/e3a07d723a8f27e9

    using T1 = string;
    using T2 = int;
    
    std::integral_constant static arity(function){ return {}; }
    std::integral_constant static arity(function){ return {}; }
    
    template
    using Arity = decltype(arity(Fn{}));
    

提交回复
热议问题