Appendix B. Utility Headers

This appendix presents the contents of “sputil.h” (in Section B.1), the header used in the examples in Chapter 2; “mathutil.h” (in Section B.2), the header used in the examples in Chapter 12; and “rgxutil.h” (in Section B.3), the header used in the exercises in Chapter 15.

B.1. “sputil.h”

#ifndef SPUTIL_H#define SPUTIL_H#include <ostream>#include <iostream>#include <memory>struct resource  { // simple struct to demonstrate resource handling  resource (int i0 = 0) : i(i0) {}  int i;  };template <class Elem, class Tr>std::basic_ostream<Elem, Tr>& operator<<(  std::basic_ostream<Elem, Tr>& str,  const resource& res)  { // insert resource contents into stream  return str << res.i;  }class d_res : public resource  { // simple derived class ...

Get The C++ Standard Library Extensions A Tutorial and Reference 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.