The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis

April 9, 2012
Publisher: Addison-Wesley Professional
ISBN: 978-0321623218

The book covers all the new C++11 library components, including

  • Concurrency
  • Fractional arithmetic
  • Clocks and timers
  • Tuples
  • New STL containers
  • New STL algorithms
  • New smart pointers
  • New locale facets
  • Random numbers and distributions
  • Type traits and utilities
  • Regular expressions

The book also examines the new C++ programming style and its effect on the standard library, including lambdas, range-based for  loops, move semantics, and variadic templates. An accompanying Web site, including source code, can be found at www.cppstdlib.com

Notes

New C++ 11 Language Features

  • Spaces in template expressions - vector<list<int>> is OK.
  • nullptr and std::nullptr_t
  • Automatic type deduction with auto
  • Uniform initialization - narrowing initializations are not possible
  • Initializer lists for user-defined types - the class template std::initializer_list<>
  • Range-based for loop (=foreach loop)
  • Move semantics (avoiding unnecessary copies and temporatires)
  • Rvalue references
  • New keywords: noexcept, constexpr, decltype 
  • Variadic templates - allow templates to accept a variable number of template arguments
  • Alias templates - support template type definitions
  • Lambdas
  • New function declaration syntax - you can declare the return type of a function behind the parameter list (it's consistent with the syntax of lambda)
  • Scope enumerations (enum class)

Standard Exception Classes

  • Language support: bad_cast, bad_typeid, bad_exception, bad_alloc, bad_weak_ptr, bad_function_call
  • Logic errors: domain_error, invalid_argument, length_error, out_of_range, future_error
  • Runtime errors: system_error, range_error, overflow_error, underflow_error

Utilities

  • pair<>, make_pair() and tuple<>, make_tuple()
  • smart pointers: shared_ptr<> and unique_ptr
  • Type traits and type utilities
  • Numeric limits
  • ratio<>, min(), max(), swap() etc.