#include <variant>
struct A;
struct B;
using C = std::variant<A, B>;
struct A
{
template <size_t n>
void fun()
{
C c;
}
};
The code I have posted compiles with g++, but not clang++. both using -std=c++17. I am not sure which one is expected, but was hoping I could get an explanation for why this happens, and if it's something that g++ specifications promise to always do, or if it's UB.
My guess is that g++ compiles various components in a different order. Templates might not be instantiated at all until they are used. But why does clang++ see the error then?