2 ms·
>Additionally, std::vector::size() is size_t and unsigned, so I decided to follow. std::string::find is size_t and unsigned too, now guess what it returns in c
by GoblinSlayer 5y ago
>Additionally, std::vector::size() is size_t and unsigned, so I decided to follow.
std::string::find is size_t and unsigned too, now guess what it returns in corner cases.
- tialaramex 5y agoWhat you have to love here is that the answer is the maximum value of the type, which is... not great but it's perhaps the best of many bad options. However the way it's typically written is -1 even though this is an unsigned type, because C++ thinks assigning negative values to unsigned variables is a completely reasonable thing to do and needn't result in a diagnostic, let alone refuse to compile...