O'Reilly logo

Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions by Herb Sutter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 39. Monoliths “Unstrung,” Part 3: std::string Diminishing

Difficulty: 5

The Slim-Fast diet continues, and std::string is indeed slimming fast.

Solution

More Operations That Can Be Nonmember Nonfriends

In this Item, we'll see that all the following functions can be implemented as non-member nonfriends:

  • resize (2)

  • assign (6)

  • += (3)

  • append (6)

  • push_back

  • insert (7—all but the three-parameter version)

Let's investigate.

resize

  1. Can string::resize be a nonmember function? Explain.

Well, let's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required