samedi 7 juillet 2018

Understanding the obscure template parameter of std::function

The std::function has a template parameter:

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

I am wondering, what type R(Args...) is, I think it is neither a function pointer T:

template<typename... Args>
using T = R(*)(Args...);

nor a function reference Q:

template<typename... Args>
using Q = R(&)(Args...);

So the type P

template<typename... Args>
using P = R(Args...);

is simply a function.

And I can declare such a function call it by:

int main(){
  P<int> myFunc;
  myFunc(3);
}

which will not compile sind myFunc has never been defined. If that is correct, where can I find more information about this type function in the standard?

Aucun commentaire:

Enregistrer un commentaire