The following snippet fails on clang with : "static_assert failed "`std::visit` requires the visitor to be exhaustive." Both gcc and vc++ accept non-const lvalue references. #include <iostream> #include <variant> struct A { int x = 33; }; struct Visitor { void operator()(A &node) { std::cout << node.x; } }; int main() { std::variant<A> var = A{}; std::visit(Visitor{}, var); }
Fixed in r294612. Thanks for the report. I'll backport this fix into the 4.0 release.