I have the following code:
#include <variant>
template <typename T>
struct S{};
using Var = std::variant<S<int>, S<float>>;
template <typename T>
concept VariantMember = requires(Var var) { std::get<T>(var); };
void foo(VariantMember auto x) {}
void foo(auto x) {}
void bar()
{
foo(S<int>{});
foo(S<char>{});
}
MSVC errors with
error C2338: get(variant<Types...>&) requires T to occur exactly once in Types. (N4835 [variant.get]/5)
This only happens if I use two instances of the same template inside the variant S in this case. So first std::get errors unexpectedly, and then the concept doesn't fail but rather errors directly. Interestingly enough if I use std::get outside of a concept, for example:
std::get<S<int>>(Var{ S<int>{} });
the code compiles fine.
Clang just seems to ignore the concept and always picks the first overload of foo in both cases.
Are those actually bugs or did I mess up?