The classical iostreams hierarchy

The <stdio.h> API suffers from at least three problems. First, the formatting functionality is far from type-safe. Second, the buffering functionality is awkwardly split up into "buffering into a file stream" (FILE * and fprintf) and "buffering into a character buffer" (snprintf). (Okay, technically, the GNU C library provides fopencookie to construct FILE * that buffers into anything you want; but this is fairly obscure and extremely non-standard.) Third, there is no easy way to extend the formatting functionality for user-defined classes; I cannot even printf a std::string, let alone my::Widget!

When C++ was being developed in the mid-1980s, the designers felt a need for a type-safe, composable, and extensible ...

Get Mastering the C++17 STL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.