2

Possible Duplicate:
What is the meaning of “… …” token?

There is a relatively new way to directly specify function types (at least, as template parameters). Don't know whether this is strictly C++11, but I've came across it while reading GCC 4.7's STL headers.

It's like this:

std::function<void(int, char**)> f;

And now, in header file <functional>, I see the following:

template <typename R, typename... A>
struct SomeStruct<R(A...)> { /* */ };

This is understandable: an explicit-specialization of SomeStruct for function types with return type R and arguments' types A.

But consider this declaration (on next line):

template <typename R, typename... A>
struct SomeStruct<R(A......)> { /* */ };

What does that double-ellipsis mean?

Community
  • 1
  • 1
intelfx
  • 2,386
  • 1
  • 19
  • 32

1 Answers1

3

I personally find it unclear, but if you know that these are equivalent, it makes more sense:

void example(int, char, ...); // C-style variadic arguments
void example(int, char...);   // equivalent: the comma before the ellipses is optional

So that specialization is just covering the case for when functions take the form:

R(A..., ...)

Such as in sprintf: R is int, A... is char* and const char*, and it's C-style variadic.

GManNickG
  • 494,350
  • 52
  • 494
  • 543