Professional C__ - Marc Gregoire [179]
If your compiler supports the new C++11 unique_ptr and shared_ptr, it is highly recommended to use them instead of the deprecated auto_ptr.
Chapter 21 discusses smart pointers in more detail.
Exceptions
The C++ language supports exceptions, which allow functions or methods to pass errors of various types up to calling functions or methods. The C++ standard library provides a class hierarchy of exceptions that you can use in your program as is, or that you can subclass to create your own exception types. Chapter 10 covers the details of exceptions and the standard exception classes.
Mathematical Utilities
The C++ library provides some mathematical utility classes. Although they are templatized so that you can use them with any type, they are not generally considered part of the standard template library. Unless you are using C++ for numeric computation, you will probably not need to use these utilities.
The standard library provides a complex number class, called complex, which provides an abstraction for working with numbers that contain both real and imaginary components.
The standard library also contains a class called valarray, which is similar to the vector class but is more optimized for high performance numerical applications. The library provides several related classes to represent the concept of vector slices. From these building blocks, it is possible to build classes to perform matrix mathematics. There is no built-in matrix class; however, there are third-party libraries like Boost that include matrix support.
C++ also provides a new way to obtain information about numeric limits, such as the maximum possible value for an integer on the current platform. In C, you could access #defines, such as INT_MAX. While those are still available in C++, you can also use the new numeric_limits template class defined in the cout << "Max int value: " << numeric_limits cout << "Lowest int value: " << numeric_limits cout << "Max double value: " << numeric_limits cout << "Lowest double value: " << numeric_limits Code snippet from numeric_limits\numeric_limits.cpp Time Utilities C++11 adds the Chrono library to the standard. It is defined in the Random Numbers C++ already had support for generating pseudo-random numbers; however, it was only very basic support. For example, you could not change the distribution of the generated random numbers. C++11 adds a complete random number library, which is much more powerful than the old C++ way of generating random numbers. The new library comes with uniform random number generators, random number engines, random number engine adaptors, and random number distributions. All of these can be used to give you random numbers more suited to your problem domain, such as normal distributions, negative exponential distributions, etc. Consult Chapter 16 for all the details on this new library. Compile-Time Rational Arithmetic The compile-time rational arithmetic library is new to C++11 and provides a ratio template class defined in the Tuples Tuples are sequences with a fixed size that can have heterogeneous elements and are defined in the