Originally Posted by
abachler
but then again, templates also only benefit a small segment of the population.
Wrong. For example, you could use templates to implement
Code:
template<int bits>
class floating {... };
and, with good specializations and good underlying libraries, get exactly what you're proposing.
Code:
floating<32> f32; // Maps to float
floating<64> f64; // Maps to double
floating<80> f80; // Maps to 80-bit long double, if available, or perhaps a truncating 128-bit long double
floating<128> f128; // Maps to 128-bit long double, if available, or perhaps SSE intrinsics
floating<1024> f1024; // Software emulation
Of course, you could also have
Code:
template <int mantissa_bits, int exponent_bits, bool denormals, bool signaling> class floating;
But of course you need very special hardware if you don't want most of these to be emulated.
Yes, it's work. But the great thing about templates is that it makes this stuff possible.