That C++ type aliases don't like recursive references to themselves.
Makes sense, right? We don't want to send the compiler into a death spiral, do we? (... Maybe)
But... A template alias used for a type that uses the alias in one of its functions also counts... wtf.
I had an alias for an In parameter type - which determines if its better as a copy or reference based on (rules). Right?
So I had:
template<typename Type>
using In = /* If small and trivial, Copy,
else Const Reference*/;
template<std::floating_point UnderlyingType>
struct Vec2
{
/*...*/
Vec2 operator+(In<Vec2> other);
};
/*...*/
void DoSomething(In<Vec2<float>> pos) { }
That looks perfectly reasonable to me.
But nope! Two-phase template name deduction be damned, that's a recursive alias... Because the operator function in Vec2 uses In, you can never have the Vec2 in the In alias.
This fails in all major compilers, with equally confusing errors in each.
So now I have to make a struct to accomplish the same thing, but in a less friendly way. Thanks C++
