This code is from an answer to another question:
template <typename F, std::size_t ... Is>
constexpr auto apply(F f, std::index_sequence<Is...>)
-> std::index_sequence<f(Is)...>
{
return {};
}
gcc fails with
<source>:5:29: error: expected parameter pack before '...'
msvc and clang compile it.
Changing it to this now causes msvc to fail:
template <typename F, std::size_t ... Is>
constexpr auto apply(F , std::index_sequence<Is...>)
-> std::index_sequence<F{}(Is)...>
{
return {};
}
<source>(5): error C2187: syntax error: '<end Parse>' was unexpected here <source>(5): error C2059: syntax error: '(' <source>(6): error C2988: unrecognizable template declaration/definition <source>(6): error C2059: syntax error: '{' <source>(6): error C2143: syntax error: missing ';' before '{'' <source>(6): error C2447: '{': missing function header (old-style formal list?)
Is this something vague in C++ standard or just an implementation bug? I see no reason why function calls should not be allowed at this place, same for construction of a F{}
.
#include <cstddef> #include <utility>
– Extemporef(Is)
is a template argument in a template-argument-list and according to temp.variadic#5.7, this should be a valid pack expansion. – Hagan