Overview: C++ Gets an Overhaul : Page 3

In this overview of the changes proposed for the new standard, you'll get an idea of the kinds of improvements you can expect this time around.

by Danny Kalev

Aug 18, 2008

Page 3 of 3

Compatibility with Other StandardsC++0x enhances compatibility with other independent International Standards. The first set of additions is designed to bring the C++ in closer agreement with the ISO/IEC 9899:1999 Standard C (C99 for short). C++0x compatibility with C99 consists of several new header files, among the rest:

The influence of the recent Unicode 4.0 standard is also reflected in C++0x. C++98 defines a wide char type called wchar_t, that has an implementation-defined size. In the mid-1990s, it was assumed that wchar_t would be sufficient for supporting Unicode but this turned out to be a false hope. The unspecified size of wchar_t prohibits portable UTF encoding in C++98. C++0x solves this problem by introducing two new character types with standardized sizes: char16_t and char32_t that are specifically designed to support portably all the Unicode 4.0 codesets and encoding schemes (UTF8, UTF16 and UTF32). Obviously, some supportfor Unicode strings in its Standard Library will be available too.

The C99 standard also introduced long long for handling 64-bit integers. C++0x fixes this incompatibility at last by adding long long and unsigned long long to its list of fundamental types. Similarly, the C++0x Standard Library defines new long long overloads of the math functions and appropriate std::complexspecializations.

Library Extensions The number of C++0x Standard Library extensions is quite overwhelming. I will list here only the more prominent extensions.

A new library for manipulating regular expressions is defined in the C++0x <regex>header. Regular expression support has been noticeably lacking in C++—especially among web programmers, designers of XML parsers, and other text-processing applications.

Back in 1997, time constraints didn't allow the standards committee to include hash tables in the first C++ standard. The new C++ standard fixes this by adding four new unordered (hash) containers: std::unordered_map, std::unordered_multimap, std::unordered_set, and std::unordered_mutiset.

Perhaps the most popular Standard Library extension is the set of new smart pointer classes: std::tr1::shared_ptr and its little known sibling, std::tr1::weak_ptr.

The class template std::tr1::array wraps a built-in array with a standard container's interface. Similarly, a tuplegroups an arbitrary number of objects of unrelated types in single, container-like object. With respect to algorithms, 11 new algorithms were voted into draft standard in June 2008. Some of these algorithms fill holes in the C++98 standard, whereas others simplify common tasks. Here are some of them:

all_of( first, last, pred): This returns true if all elements in the range satisfy the predicate pred

any_of( first, last, pred): This returns true if any element in the range satisfies pred

copy_n(first, n, result): This copies n elements into the result

iota( first, last, value): For each element in the range, this assigns value and pre-increment value by ++value

none_of( first, last, pred): This returns true if none of the elements in the range satisfies pred

Finally, the rangeand subrange class templates of C++0x bundle pairs of iterators, thus significantly simplifying certain sequence operations and compacting the signatures of many popular algorithms.

The Road AheadThe vast number of new features forces the committee to work at an incredible speed. A clear statement of intent was made to complete work on the new standard at the San Francisco meeting of September 2008 in order to achieve publication in 2009. To meet this ambitious timetable the plan is to vote out a feature complete Working Draft at the next meeting. A Final Committee Draft will be issued from the following meeting, allowing at least a minimal time for review and "integration testing" of the new features—particularly a conceptualized Standard Library.