https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89611
Bug ID: 89611 Summary: Compilation ok with 'class', but ko with 'struct' Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xavier at cremaschi dot fr Target Milestone: --- $ g++ --version g++ (Debian 8.2.0-21) 8.2.0 The following code compiles : #include <string> #include <iostream> #include <variant> using namespace std; template<class... Ts> struct Visitor : Ts... { using Ts::operator()...; }; template<class... Ts> Visitor(Ts...) -> Visitor<Ts...>; int main() { std::variant<int, string> package; auto x = Visitor { [](int) { cout << "int\n"; }, [](string) { cout << "string\n"; }, } ; std::visit(x, package); } But if I replace 'struct Visitor' by a class and add public visibility, it doesn't : #include <string> #include <iostream> #include <variant> using namespace std; template<class... Ts> class Visitor : Ts... { public: using Ts::operator()...; }; template<class... Ts> Visitor(Ts...) -> Visitor<Ts...>; int main() { std::variant<int, string> package; auto x = Visitor { [](int) { cout << "int\n"; }, [](string) { cout << "string\n"; }, } ; std::visit(x, package); } AFAIK class or struct is just a matter of default visibility, so I think both cases should work.