I am looking through another developer code that contains the following:
std::string name;
...
std::string::size_type colon = name.find(":");
I would argue that the use of size_tit would be easier to understand and is as safe as the STL standard states that std::stringhave std::basic_string<char, std::allocator>, and std::allocator::size_type- size_t.
He wants to make sure that the STL standard cannot ever change to invalidate this assumption; if the standard can change, then it size_typewill be safer than size_t.
Could this happen? Is there any other reason to use size_type, not size_t?
source
share