According to cppreference :
- an empty substring is found in pos if and only if pos <= size ()
str.find("")uses the third overload for std::basic_string::find, which has a signature:
size_type find( const CharT* s, size_type pos = 0 ) const;
This means that it posstarts with 0, therefore it is pos <= size()always true.
Yes, the behavior is well defined and tolerable.
source
share