c++ - Why call basic_string::substr with no arguments? -



c++ - Why call basic_string::substr with no arguments? -

if s1 , s2 strings, (as far can tell)

s1 = s2.substr();

means same as

s1 = s2;

why want phone call substr() without arguments?

edit: way phrase same question:

why standard define substr thus:

basic_string substr( size_type pos = 0, size_type count = npos ) const;

rather thus:

basic_string substr( size_type pos, size_type count = npos ) const;

the reply is, heck of it. rightly noticed, has no advantage (and speed disadvantage) creating copy.

speculating why first argument defaulted @ all, guess meant way forcefulness un-sharing of ancient cow strings (not allowed current standards). or over-zealous when adding default arguments. happens best of us.

c++ stdstring

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -