I'm not understanding why this is not working:
template <typename ... Types>
void func()
{
(std::cout << typeid(Types).name(), ...) ; // Syntax error, unexpected token '...', expected 'expression'
(static_assert(std::is_integral_v<Types>, "Type must be integral type"), ...); // Syntax error: unexpected token 'static_assert', expected 'expression'
}
int main()
{
func<int, short>();
}
My understanding is that the compiler should basically go:
(static_assert(std::is_integral_v<Types>, "Error message"), ...)
The comma is an operator and what's before the operator should get repeated for each type in the parameter pack. Why isn't this working?