Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c++1z] std::visit does not accept visitors which require non-const lvalue references #31264

Closed
bmanga opened this issue Feb 9, 2017 · 1 comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@bmanga
Copy link

bmanga commented Feb 9, 2017

Bugzilla Link 31916
Resolution FIXED
Resolved on Feb 09, 2017 13:02
Version unspecified
OS All
CC @mclow

Extended Description

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
#include

struct A { int x = 33; };

struct Visitor
{
void operator()(A &node) { std::cout << node.x; }
};
int main()
{
std::variant var = A{};
std::visit(Visitor{}, var);
}

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 9, 2017

Fixed in r294612. Thanks for the report. I'll backport this fix into the 4.0 release.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

2 participants