APPENDIX D

C++11

This appendix explains new features in the C++ 2011 standard, informally called C++11, that are used in this book. These features are available in several widely used C++ compilers. This is not intended to be a full tutorial on these features, but should provide enough information to enable understanding of the examples. It also explains suitable substitutes for use with C++ 1998 compilers.

D.1 Declaring with auto

C++11 permits the auto keyword to be used in place of a type in some contexts where the type can be deduced by the compiler. Here is an example:

std::vector<double> v;

for (auto i = v.begin(); i ! = v.end(); ++i)

  auto& x = *i;

}

The C++98 equivalent would be:

std::vector<double> v;

for (std::vector<double>::iterator ...

Get Structured Parallel Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.