Get argument type of template callable object

后端 未结 4 1566
不知归路
不知归路 2020-12-09 04:33

Consider the following function:

template
void register_handler( F& f ) // any callable object
{
   // find out T - the argument type of f         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 04:52

    Assuming F is any callable type, you cannot get its argument type. Consider this:

    struct callable
    {
        void operator() (int);
        void operator() (float *);
        void operator() (std::string const &);
        void operator() (std::list &);
    };
    

    the type of argument is an ambiguity here.

提交回复
热议问题