سؤال

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