An Interesting C++ Templated Parameter Gotcha(digitalpeer.com)
digitalpeer.com
An Interesting C++ Templated Parameter Gotcha
http://www.digitalpeer.com/blog/an-interesting-cpp-templated-parameter-gotcha
1 comments
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.
Suggesting 0LL is just calling for trouble when someone realizes the vector didn't had to be long long and forgets to change the initialized value.
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.