xxiv
■ IntroduCtIon
Templates from other headers such as <pair>, <tuple>, <functional>, and <memory> also get dragged
in to the book at various points. The templates for data containers are fundamental; these will be useful in
the majority of applications. Iterators are a basic tool for working with containers so they are included also.
Algorithms are function templates that operate on data stored in containers. These are powerful tools that
you can also apply to arrays and they are described and illustrated with working examples. I have included
a chapter that explains the templates that relate to random number generation and statistics. While some of
these are quite specialized, many are widely applicable in simulations, modeling, and games programs. The
templates for compute-intensive numerical data processing are discussed, and those relating to time and
timing. Finally, there’s a brief introduction to the class templates for working with complex numbers.
Prerequisites for Using the Book
To understand the contents of this book you need to have a basic working knowledge of the C++ language.
This book complements my Beginning C++ book, so if you have worked through that successfully, you’re in
good shape to tackle this. A basic understanding of what class templates and function templates are, and
how they work is essential, and I have included an overview of the basics of these in Chapter 1. If you are
not used to using templates, the syntax can give the impression that they are lot more complicated than
they really are. Once you get used to the notation, you’ll find them relatively easy to work with. Lambda
expressions are also used frequently with the STL so you need to be comfortable with those too.
You’ll need a C++ 14-compliant compiler and of course a text editor suitable for working with program
code. There has been quite a renaissance in C++ compiler development in recent years, and there are several
excellent compilers out there that are largely in conformance with C++ 14, in spite of it being a recently
approved standard. There are at least three available that you can use without charge:
• GCC is the GNU compiler collection that supports C++, C, and Fortran as well as
other languages. GCC supports all the C++ 14 features used in this book. You can
download GCC from gcc.gnu.org. The GCC compiler collection works with GNU and
Linux, but there’s a version for Microsoft Windows that you can download from
www.mingw.org.
• The ideaone online compiler supports C++ 14 and is accessible through ideaone.com.
The compiler it uses for C++ 14 is GCC 5.1 at the time of writing. ideaone.com also
supports a wide range of other programming languages, including C, Fortran,
and Java.
• The Microsoft Visual Studio 2015 Community Edition runs under the Microsoft
Windows operating system. It supports C++ as well as several other programming
languages and comes with a complete development environment.
Using the Book
For the most part, I have organized the material in this book to be read sequentially, so the best way to
use the book is to start at the beginning and keep going until you reach the end. Generally, I try not to use
capabilities before I have explained them. Once I have explained something, I plug it in to subsequent
material whenever it makes sense to do so, which is why I recommend going through the chapters
sequentially. There are a few topics that require some understanding of the underlying mathematics, and
I have included the maths in these instances. If you are not comfortable with the maths, you can skip these
without limiting your ability to understand what follows.