
26 Sep
2011
26 Sep
'11
2:51 p.m.
Olaf van der Spek wrote:
Christian Holmquist wrote:
enum A{a}; enum B(b); main() { clamp(0, a, b); }
Right. g++ 4.6: warning: enumeral mismatch in conditional expression: 'A' vs 'B'
Is this really the fault of clamp() though? The same 'mistake' can easily be made in normal code.
The original C had a weaker type system than what is offered by the template system in C++. Because of backwards compatibility with C, many of the issues caused by this weaker type system had to stay around in C++. But this shouldn't be used as an argument in favor of duplicating such issues in template based code were they could easily be avoided. Regards, Thomas