- ( ):
#define COUNT_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define COUNT(...) COUNT_N(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
#define ARG1(S, ...) S
- :
#define MyVariadic_And_Check(...) do { \
Check(ARG1(__VA_ARGS__), COUNT(__VA_ARGS__) - 1); \
MyVariadic(__VA_ARGS__); } while(false)
Check(const char* format, int count) .
. MyVariadic const char* format, COUNT .
++ 11 - :
template <typename ... Args>
void MyVariadic_And_Check(const char* format, Args&&...args);
to check the quantity and type.
source
share