User:Tacvek/C++0x

This page is a very rough attempt to create a guide to the new features of C++09 for people already familiar with c++03. It is based on n2606.pdf

TODO:
 * Research the unknowns.
 * Mention the type-generic header inclusion.
 * Other headers added like the wchar header.

Boolean Datatypes
C99 has a _Bool datatype that is generally used via the 'bool' macro (as well as true and false macros) found in &lt;stdbool.h&gt;. These definitions are compatible with the c++ keywords bool, true, and false.

Therefore, the C++0x standard adds a &lt;stdbool.h&gt; and &lt;cstdbool&gt; headers for compatibility. These headers simply define the __bool_true_false_are_defined macro as per the C99 standard.

The C++0x standard does not include the _Bool keyword. This does not hurt compatibility significantly, as few C programs use that keyword directly.

Complex Numbers
TODO

C99 Preprocessor additions
C++0x supports the _pragma keyword from C99. It also includes support for variable-length argument macros using __VA_ARGS__ (like in C99). I've not yet determined if it supports empty macro arguments or VARGS macros.

&lt;stdint.h&gt;
C++0x includes &lt;stdint.h&gt; of C99, as well as a &lt;cstdint&gt; header, with the typedefs in the std namespace.

long long ints
C++9x includes the C99 'long long datatype (as well as the more explicit long long int), as well as it's unsigned variation. It also includes the relevant additions to &lt;limits.h&gt; and &lt;climits&gt;. However, _Longlong and _ULonglong marcos/typedefs required by C++03TR1 are not included in C++0x. I'm not sure if c++0x includes the new type specifiers for printf and scanf.

__func__
C99's __func__ predefined value is present, containing an implementation defined string.

Array Parameter Qualifier
It is not clear to me if the array parameter qualifier feature of C99 is in C++0x. For example:  or

Compound literals
I've yet to determine if C++0x supports C99's compound literals.

Designated initializers
I've yet to determine if C++0x supports C99's designated initializers.

Variable Length Arrays
I've yet to determine if C++0x supports C99's variable length arrays.

Flexible Array Member (struct hack)
I've yet to determine if C++0x supports C99's Flexible array member feature.

restrict
I've yet to determine if C++0x supports C99's restrict feature.

Hexadecimal floating-point literals
Why not?

One could almost implement this as a user-defined literal, but not quite. That seems odd to me.

Type Determinism
TODO: If a variable is declared with a specific initialization, it may use the specifier auto without a type specifier, and the compiler will determine the type of the right hand side of the initialization, and use that as the type.
 * Explain uses
 * Provide examples

There is a new pseudo-function keyword decltype, it takes as an argument an expression. It determines the type of the expression result at compile time. It functions as though it were replaced with the correct type specification for the result type of the expression. (CHECKME: I think it can be used where ever a type name can be used).

nullptr
To fix the issue of NULL being both an integer and a pointer type, and to make the name even clearer, there is a new keyword nullptr. It designates a constant r-value of a new unnamed datatype. (The datatype can have a name, but it must be using an implementation reserved name, or be otherwise inaccessible, such as defined in an unnamed namespace.) It is effectively a simple POD struct with implicit conversion operators to any pointer or pointer to member datatype. (Either by templated member functions, or by compiler magic.) While it is not expected to be very useful, the   header will contain a new typedef of the form typedef decltype(nullptr) nullptr_t; or equivalent.