Skip to Content
Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions
book

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

by Herb Sutter
August 2004
Intermediate to advanced
352 pages
7h 38m
English
Addison-Wesley Professional
Content preview from Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Herb Sutter
Navigating C++ and Object-Oriented Design

Navigating C++ and Object-Oriented Design

Paul Anderson, Gail Anderson

Publisher Resources

ISBN: 0201760428Purchase book