What's new for IBM i 7.3
In addition to the existing C++11 features, new C++11 features are supported in this release of ILE C++ compiler.
- Defaulted and deleted functions
- Explicit conversion operators
- Generalized constant expressions
- Reference collapsing
- Right angle brackets
- Rvalue references
- Scoped enumerations
- The nullptr keyword
- Trailing return type
- Variadic template
You can use the LANGLVL(*EXTENDED0X) option to enable most of the C++ features and all the currently supported C++11 features.
- Defaulted and deleted functions
- This feature introduces two new forms of function declarations to define explicitly defaulted functions and deleted functions. For the explicitly defaulted functions, the compiler generates the default implementations, which are more efficient than manuallyprogrammed implementations. The compiler disables the deleted functions to avoid calling unwanted functions.
For more information, see Explicitly defaulted functions (C++11) and Deleted functions (C++11).
- Explicit conversion operators
- The explicit conversion operators feature supports the explicit function specifier being applied to the definition of a user-defined conversion function. You can use this feature to inhibit implicit conversions from being applied where they might be unintended, and thus program more robust classes with fewer ambiguity errors.
For more information, see Explicit conversion operators (C++11).
- Generalized constant expressions
- The generalized constant expressions feature extends the expressions permitted within constant expressions. A constant expression is one that can be evaluated at compile time.
For more information, see Generalized constant expressions (C++11).
- Reference collapsing
-
With the reference collapsing feature, you can form a reference to a reference type using one of the following contexts:
- A decltype specifier
- A typedef name
- A template type parameter
For more information, see Reference collapsing (C++11).
- Right angle brackets
- In the C++ language, two consecutive closing angle brackets (>) must be separated with a white space, because they are otherwise parsed as the bitwise right-shift operator (>>). The right angle bracket feature removes the white space requirement for consecutive right angle brackets, thus making programming more convenient.
For more information, see Class templates (C++ only).
- Rvalue references
- With the rvalue references feature, you can overload functions based on the value categories of arguments and similarly have lvalueness detected by template argument deduction. You can also have an rvalue bound to an rvalue reference and modify the rvalue through the reference. This enables a programming technique with which you can reuse the resources of expiring objects and therefore improve the performance of your libraries, especially if you use generic code with class types, for example, template data structures. Additionally, the value category can be considered when writing a forwarding function.
For more information, see References (C++ only).
- Scoped enumerations
-
With the scoped enumeration feature, you can get the following benefits:
- The ability to declare a scoped enumeration type, whose enumerators are declared in the scope of the enumeration.
- The ability to declare an enumeration without providing the enumerators. The declaration of an enumeration without providing the enumerators is referred to as forward declaration.
- The ability to specify explicitly the underlying type of an enumeration.
- Improved type safety with no conversions from the value of an enumerator (or an object of an enumeration type) to an integer.
For more information, see Enumerations.
- The nullptr keyword
- This feature introduces nullptr as a null pointer constant. The nullptr constant can be distinguished from integer 0 for overloaded functions. The constants of 0 and NULL are treated as of the integer type for overloaded functions, whereas nullptr can be implicitly converted to only the pointer type, pointer-to-member type, and bool type.
For more information, see Null pointers.
- Trailing return type
-
The trailing return type feature is useful when declaring the following types of templates and functions:
- Function templates or member functions of class templates with return types that depend on the types of the function arguments
- Functions or member functions of classes with complicated return types
- Perfect forwarding functions
For more information, see Trailing return type (C++11).
- Variadic templates
- With the variadic templates feature, you can define class or function templates that have any number (including zero) of parameters.
For more information, see Variadic templates (C++11).