Do you see anything wrong with this code?
int l = v.size();
Well, it seems that a lot of ISV’s don’t as I’ve encountered it many times.
If you compile for 32-bit at warning level 4, you don’t get any message. But if you target 64-bit, you get:
warning C4267: ‘initializing’ : conversion from ‘size_t’ to ‘int’, possible loss of data
size_t is 64-bit on 64-bit platform but an int is still 32-bit! Not only that but size_t is always unsigned. From CRTDefs.h:
typedef unsigned __int64 size_t;
typedef unsigned int size_t;
If we would have had C++ 0x sooner, more people would have just used the auto keyword and that problem would have mostly gone away…
The wcslen() function and the sizeof operator are other examples that return an instance of size_t.
I’d rather have a good look at the API documentation and still use auto. You might differ though. If so, drop me a comment.