Please consider the following variadic:
1 2 3 4 5
|
template<typename... Args>
constexpr bool check1()
{
return All(Convertible<Args, size_t>()...);
}
|
Convertible() and All() are shown below for reference:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
template<typename X, typename Y>
constexpr bool Convertible()
{
return true; /// dummy implementation
}
/// checks if all arguments are true.
constexpr bool All() /// recursion terminator
{
return true;
}
template<typename... Args>
constexpr bool All(bool b, Args... args)
{
return b && All(args...);
}
|
Focusing attention back on the check1() variadic shown above and the statement within it:
1 2 3 4 5
|
template<typename... Args>
constexpr bool check1()
{
return All(Convertible<Args, size_t>()...);
}
|
Evidently the statement is supposed to ensure that all the argument types (Args parameter pack) are convertible to size_t.
However, I don't understand how the expansion can work.
Convertible<Args, size_t>() returns a bool. Therefore, the statement reduces to:
This is nonsensical. Only an argument pack can be expanded.
How does the expansion affect the Args parameter pack, since it is located outside the function call?
It should have been Args... or args... (but args is not declared in the example), but that would be wrong syntax and semantics for the Convertible function defined above.
Basically, I'd like to understand the syntax of the return All(Convertible<Args, size_t>()...) statement.
Thanks.