Exploring C++ 11: Problems and Solutions Handbook
Exploring C++ 20 is now available.
Almost all the code listings for Exploring C++ 11
are here, grouped by chapters.
Some of the listings have been fleshed out from what appears in the book.
For example, most "omitted for brevity" and similar statements are
replaced by the relevant code.
The code has been compiled and checked with clang 3.3
and g++ 4.8.
Download all the files in a single ZIP.
Microsoft Visual Studio 2013 lacks several
key features,
such as constexpr, noexcept, inheriting constructors, and defaulted move functions,
all features that are used heavily in these examples.
Although one can work around some of these limitations,
that work is left as an exercise for the reader.
Working around the lack of constexpr is a big job because
it means rewriting functions as template metafunctions.
Perhaps the next release of Visual Studio will support the entire C++ 11 standard.
Some projects require sample text files, especially when exploring international locales.
See the data directory for files.
The file name indicates the character set.
Samples were excerpted from Wikipedia.
See data/sample-utf8.txt for links to the source for each excerpt.
- Honing Your Tools
- Reading C++ Code
- Integer Expressions
- Strings
- Simple Input
- Error Messages
- For Loops
- Formatted Output
- Arrays and Vectors
- Algorithms and Iterators
- Increment and Decrement
- Conditions and Logic
- Compound Statements
- Introduction to File I/O
- The Map Data Structure
- Type Synonyms
- Characters
- Character Categories
- Case-Folding
- Writing Functions
- Function Arguments
- Using Algorithms
- Unnamed Functions
- Overloading Function Names
- Big and Little Numbers
- Very Big and Very Little Numbers
- Documentation
- Project 1: Body-Mass Index
- Custom Types
- Overloading Operators
- Custom I/O Operators
- Assignment and Initialization
- Writing Classes
- More About Member Functions
- Access Levels
- Introduction to Object-Oriented Programming
- Inheritance
- Virtual Functions
- Classes and Types
- Declarations and Definitions
- Using Multiple Source Files
- Function Objects
- Useful Algorithms
- Iterators
- Exceptions
- More Operators
- Project 2: Fixed-Point Numbers
- Function Templates
- Class Templates
- Template Specialization
- Partial Specialization
- Names and Namespaces
- Containers
- Locales and Facets
- International Characters
- Text I/O
- Project 3: Currency Type
- Pointers
- Dynamic Memory
- Moving With Rvalue References
- Exception-Safety
- Old-Fashioned Arrays
- Smart Pointers
- Working with Bits
- Enumerations
- Multiple Inheritance
- Traits and Policies
- Names and Templates
- Overloaded Functions
- Metaprogramming
- Project 4: Calculator