Prefer nonmember, nonfriends?
How many member functions does std::string
have?
As of C++17 the answer is 153, assuming I counted correctly.
One Hundred Fifty Three.
That is a lot. And as Herb Sutter has pointed out, most of those members could easily be implemented as non-members without loss of performance.
And they should be implemented as nonmembers according to an old guideline from the C++ coding standards: Prefer nonmember, nonfriends. Write free functions whenever possible, not members.
But how true is that advice really?
» read more »