Simple question for which I could not find answer on the net. In variadic argument macros, how to find the number of arguments? I am okay with boost preprocessor, if it has
There are some C++11 solutions for finding the number of arguments at compile-time, but I'm surprised to see that no one has suggested anything so simple as:
#define VA_COUNT(...) detail::va_count(__VA_ARGS__)
namespace detail
{
template
constexpr std::size_t va_count(Args&&...) { return sizeof...(Args); }
}
This doesn't require inclusion of the
header either.