[libcxx-dev] std::variant<> and overload resolution

Brian Cain via libcxx-dev libcxx-dev at lists.llvm.org
Wed Aug 25 06:03:54 PDT 2021


For the test case below, clang++-12 does not emit an error (likely the same on ToT).  Nor does g++-9.4.0 with libstdc++.  But should they?  I suppose "23.7.3.1 Constructors" of C++17 is the relevant specification.  Can anyone clarify?  I'm not quite sure: is this particular overload resolution issue more of a compiler or library issue?

$ clang++ -fsyntax-only -std=c++17 -x c++ -c test_case.cpp -stdlib=libc++

~~~~

#include <variant>

struct A {} const a;

template <class T> struct S{
    S(T&&...) {}
    S(int) {}
};

std::variant<int, S<A>> b(1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20210825/22b5cc5b/attachment.html>


More information about the libcxx-dev mailing list