Chapter 31. Return Value Lifetime

This chapter contains much of the material from a series of installments of Flexible C++, my C/C++ User's Journal Expert's Forum column [Wils2003d, Wils2003f, Wilson2004b]. It revolves around the seemingly trivial problem of converting integers to strings in an efficient manner.

As it turns out, it's anything but a trivial issue when the details start to come out, and as well as illustrating some practical ramifications of many of the issues covered in the book so far, it brings into sharp focus the issue of Return Value Lifetime (RVL) which we discussed in the section on Conversion Shims (see sections 16.2 and 20.5).

Probably the most common way to convert integers to strings is via sprintf(), whether called directly ...

Get Imperfect C++ Practical Solutions for Real-Life Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.