C++0x

C++0x is the working draft of the new C++ programming language standard. Additional C++0x features are supported in this release of XL C/C++.

Note: C++0x is a new version of the C++ programming language standard. This is a draft standard and has not been officially adopted in its entirety. The implementation of C++0x is based on IBM's interpretation of the draft C++0x standard and is subject to change at any time without notice. IBM makes no attempt to maintain compatibility with earlier releases and therefore the C++0x language extension should not be relied on as a stable programming interface.
The following features are introduced in XL C/C++ V11.1:

Auto type deduction

With the auto type deduction feature, you no longer need to specify a type while declaring a variable. This is because auto type deduction delegates the task of deducting the type of an auto variable to the compiler from the type of its initializer expression.

You can use the individual suboption -qlanglvl=autotypededuction or the group option -qlanglvl=extended0x to enable this feature.

For more information, see The auto type specifier (C++0x).

C99 long long

The C++ compiler can use the C99 long long feature, which improves source compatibility between the C and C++ languages.

You can use the individual suboption -qlanglvl=c99longlong or the group option -qlanglvl=extended0x to enable the C99 long long feature.

IBM extension After this feature is enabled, if a decimal integer literal that does not have a suffix containing u or U cannot be represented by the long long int type, you can decide whether to use the unsigned long long int type to represent the literal or not by specifying the -qlanglvl=[no]extendedintegersafe option.

For more information, see Integer literals.

C99 preprocessor features adopted in C++0x

With several C99 preprocessor features adopted in C++0x, C and C++ compilers provide a more common preprocessor interface, which can ease porting C source files to the C++ compiler, eliminate semantic differences between the C and C++ preprocessors, and avoid preprocessor compatibility issues or diverging preprocessor behaviors.

You can use the individual suboption -qlanglvl=c99preprocessor or the group option -qlanglvl=extended0x to enable this feature.

For more information, see C99 preprocessor features adopted in C++0x (C++0x).

Decltype

With the decltype feature, you can get a type that is based on the resultant type of a possibly type-dependent expression.

You can use the individual suboption -qlanglvl=decltype or the group option -qlanglvl=extended0x to enable this feature.

For more information, see The decltype(expression) type specifier (C++0x).

Delegating constructors

With the delegating constructors feature, you can concentrate common initializations in one constructor, which makes programs more readable and maintainable.

You can use the individual suboption -qlanglvl=delegatingctors or the group option -qlanglvl=extended0x to enable this feature.

For more information, see Delegating constructors (C++0x).

Explicit instantiation declarations

With the explicit instantiation declarations feature, you can suppress the implicit instantiation of a template specialization or its members.

You can use the individual suboption -qlanglvl=externtemplate or the group options -qlanglvl=extended and -qlanglvl=extended0x to enable this feature.

For more information, see Explicit instantiation (C++ only).

Extended friend declarations

The extended friend declarations feature relaxes the syntax rules governing friend declarations as follows:
  • Template parameters, typedef names, and basic types can be declared as friends.
  • The class-key in the context for friend declarations is no longer necessary in C++0x.

You can enable this feature with the individual suboption -qlanglvl=extendedfriend or the group option -qlanglvl=extended0x.

For more information, see Friends (C++ only).

Inline namespace definitions

Inline namespace definitions are namespace definitions with an initial inline keyword. You can define or specialize the members of an inline namespace as if they belong to the enclosing namespace that contains the inline namespace.

You can enable this feature with the individual suboption -qlanglvl=inlinenamespace or the group option -qlanglvl=extended0x.

For more information, see Inline namespace definitions (C++0x).

Static assertion

The static assertion feature provides you with the following benefits:
  • Libraries can detect common usage errors at compile time.
  • Implementations of the C++ Standard Library can detect and diagnose common usage errors, thus improving usability.
You can use a static_assert declaration to check important program invariants at compile time.

You can enable the static assertion feature with the individual suboption -qlanglvl=static_assert or the group option -qlanglvl=extended0x.

For more information, see static_assert declaration (C++0x).

Variadic templates

With the variadic templates feature, you can define class or function templates that have any number (including zero) of parameters.

You can use the individual suboption -qlanglvl=variadic[templates] or the group option -qlanglvl=extended0x to enable this feature.

For more information, see Variadic templates (C++0x).