Following the stackoverflow question: "Variadic macros with zero arguments, and commas", I tried:

#define MAKE_TEMPLATE(...) template <typename T, ## __VA_ARGS__ >

MAKE_TEMPLATE()
struct Testing{};

Compiler gives: error: expected identifier before '>' token

But g++ -E main.cpp (to get macro expansion) show:

template <typename T >
struct Testing{};

And with:

MAKE_TEMPLATE(typename U)
struct Testing{};

It compile OK. Whats missing?

有帮助吗?

解决方案

http://en.wikipedia.org/wiki/Variadic_macro: GCC supports the following (non-portable) extension: ## __VA_ARGS__

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top