Re:An Interesting C++ Templated Parameter Gotcha
by DerKommissar on Sunday February 23, 2014 @12:30PM
(#7286606)
Unrelated to the post but related to the code you wrote - I have found that changing the tag struct definition to a declaration will cause a compilation failure if something accidentally tries to instantiate the tag struct.
IMO one of the huge screw ups of the design of the STL is making sizes unsigned. It means that you get a compiler error when writing:
since i and size() have different types. The worst part is that unsigned doesn't buy you that much (only twice as many elements).The lesson to be learned here is: don't use weird integer types unless you really need to, and then, you should know what you are doing. E.g. if I need a long index then I use
when I'm hacking, and when I'm serious to disable all implicit conversions and make these types of errors impossible.