[llvm-bugs] [Bug 31916] New: [c++1z] std::visit does not accept visitors which require non-const lvalue references

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 9 03:02:40 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31916

            Bug ID: 31916
           Summary: [c++1z] std::visit does not accept visitors which
                    require non-const lvalue references
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bruno.manga95 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

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);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170209/ef0cd76a/attachment.html>


More information about the llvm-bugs mailing list