The cppreference overloaded "trick" where each variant can be visited through a templated operator()
overload doesn't compile with the Visual C++ compiler. Code snippet can be found here and executes fine when compiled with clang or gcc.
However, this doesn't compile with MSVC (see on godbolt):
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
It throws various errors and ultimately fails:
warning C4346: 'Ts::()': dependent name is not a type
note: prefix with 'typename' to indicate a type
note: see reference to class template instantiation 'overloaded<Ts...>' being compiled
error C2143: syntax error: missing ';' before '...'
error C2059: syntax error: '...'
error C2238: unexpected token(s) preceding ';'
error C2988: unrecognizable template declaration/definition
error C2143: syntax error: missing ')' before '...'
error C2143: syntax error: missing ';' before '...'
error C2365: 'Ts': redefinition; previous definition was 'template parameter'
note: see declaration of 'Ts'
error C2059: syntax error: ')'
error C2059: syntax error: '->'
error C2065: 'Ts': undeclared identifier
error C3544: 'Ts': parameter pack expects a type template argument
Is there an alternative? Am I missing options for the compiler?