This question has already been answered here:
Why does C++ mandate that complex only be instantiated for float, double, or long double?
However, I do not see how the answer there is valid. The accepted reason is that:
You can't properly implement many of the std::complex operations on integers. E.g.,
template T abs(const complex &z);
for a complex cannot have T = long return value...
However, I don't see any reason why not.
For example, if I have 1234567 + 7654321i
, then the abs() is about 7753243.557. An integer result such as 7753243 or 7753244 could be highly useful. It doesn't matter which result is given, as long as the mechanism is consistent. (In the same way that we accept 5 / 3 = 1).
Could anyone offer any ideas as to why complex integers are not available?