1

I've looked at a partial template specialization argument-list and stumbled upon such an example

template <typename>
class function;
template <typename ReturnValue, typename Args,typename Args2>
class function<ReturnValue(Args,Args2)>
{
    //smth
};

What exactly means ReturnValue(Args,Args2) (couse it's not a type as I know) and by what rules can I write similar things?

Thanks

Poarthur
  • 53
  • 1
  • 5
  • 3
    This is [function signature template](https://stackoverflow.com/questions/4642079/function-signature-like-expressions-as-c-template-arguments). Details actually can be found in this [book](https://en.wikipedia.org/wiki/Modern_C%2B%2B_Design) – Victor Gubin Apr 25 '19 at 08:33
  • `ReturnValue(Args,Args2)` *is* a type (a function returning type `ReturnValue` and taking two arguments of type `Args` and `Args2`). – WhozCraig Apr 25 '19 at 08:35

1 Answers1

4

couse it's not a type as I know

Actually, it is. ReturnValue(Args,Args2) is the type "function taking Args and Arg2 and returning ReturnValue". Take this example:

void foo(int, char);
typedef void FunctionType(int, char);

Here, FunctionType is indeed the type void(int, char), which is also the type of foo.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455