I'm reviewing another developer's code, which contains the following:
std::string name;
...
std::string::size_type colon = name.find(":");
I'm arguing that using size_t would be easier to understand and just as safe, since the STL standard states that std::string is std::basic_string<char, std::allocator>, and std::allocator::size_type is size_t.
He wants assurance that that the STL standard couldn't possibly ever change to make this assumption invalid; if the standard could change, then size_type would be safer than size_t.
Could that happen? Is there any other reason to use size_type rather than size_t?
size_typeshould be used in code templated on the container type. When the code you have always operates onstd::string, you can just usesize_t.