1

Regarding the definition of the std::function,

template< class R, class... Args >
class function<R(Args...)>;

And the instantiation of the template is like this:

std::function<int(Foo const&)> f_num = &Foo::num_;

I'm confusing that how the parameter can be used like this: int(Foo const&). int and Foo const& are both types.

newonelei
  • 21
  • 2
  • There doesn't seem to be any deduction going on in your instantiation. – nwp Mar 04 '18 at 16:51
  • `R` and `Args` are also types, so no problem. The fact that the template uses `class` and not `typename` [doesn't matter at all](https://stackoverflow.com/questions/213121/use-class-or-typename-for-template-parameters?rq=1). – Bo Persson Mar 04 '18 at 17:04
  • Possible duplicate of [Function signature-like expressions as C++ template arguments](https://stackoverflow.com/questions/4642079/function-signature-like-expressions-as-c-template-arguments) – Klaus Mar 04 '18 at 17:14
  • oh, yep, thanks @Klaus – newonelei Mar 04 '18 at 19:19
  • also, this article should be helpful https://stackoverflow.com/questions/17446220/c-function-types – newonelei Mar 04 '18 at 19:33

0 Answers0