edit note: originally question said illegal where now it says unspecified.
Thanks to video comment section of Jason Turner video recently I learned that std::complex<int>
is unspecified.
But all(AFAIK) implementations seem to happily compile
std::complex<int>
But some functions like std::abs()
are broken for std::complex<int>
, so it's not actually usable in those mainstream implementaitons.
I wonder if there is some reason why detection for "bad" types was never implemented. I know that std lib implementations need to work with older standards so they can not just stuck std::floating_point
concept everywhere, but even before C++20 we had ways to constrain templates.
In other words: is this just "would be nice, but we dont have time" issue, or is there some compatibility reason to keep this compiling. Only thing I can think of is that some people are using std::complex and std lib "manufacturers" do not want to obviously break their already broken code.