Think about the difference between what you've done there and the scenario that I just described. To illustrate:
Originally Posted by manasij7479
void funcThatRequiresNonEmpty_C_String( const char* string ) // <-- And yes, some poorly written C style APIs assume on blind faith that they get a non-empty string.
assert( std::strlen( string ) > 0 );
const std::string badIdea( 20, '\0' );
if ( ! badIdea.empty() )
funcThatRequiresNonEmpty_C_String( badIdea.c_str() );