I was reading about std::function
in part 3 this (long) answer on callbacks in C++ https://stackoverflow.com/a/28689902/3832877 and it demonstrates the use template arguments which have additional types in parentheses. Examples of what I mean:
std::function<int(int, float)> foo; //for a function returning int with one int and one float argument
std::function<int(C const &, int)> moo; //from the above thread, for member function of class C taking one int argument and returning int
I understand the usage in std::function
to define the function signature, but I don't understand how the compiler is parsing these template arguments. What do the types in the parentheses mean to the compiler? Are there any other uses for this syntax or was it created specifically for std::function
and related STL classes? Can I write my own classes that use this syntax?