HP aC++ Release Notes Version A.03.95 (5900-1789; September 2011)

HP aC++ Release Notes
New Features in Version A.03.27
Chapter 156
Transitioning from the Prior to the New Standard C++ Library
The following topics discuss changes when transitioning from the prior version to the new Standard C++
library:
Source Code Changes
Since the new Standard C++ Library (libstd_v2) includes the new iostream library and has namespace
std enabled, significant changes may be required in your source code. For example, the following program
will no longer compile:
#include <iostream> // ported from <iostream.h>
int main() {
cout << “Hello, World” << endl;
}
Because both cout and endl are now in namespace std, they must be referenced as std::cout and
std::endl. Alternatively, using declarations or using directives can be added to your code to make them
visible outside of the namespace std scope. The following is correct:
#include <iostream>
int main() {
std::cout << “Hello, World” << std::endl;
}
iostream_compat Directory
To help with code transition to the new C++ standard, an iostream_compat directory is provided. It
contains some header files that are just wrappers. You can include files in the iostream_compat directory
even when specifying the -AA option, to make symbols like cout visible in global scope.
For example, <iostream.h> is in iostream_compat, and it includes the new <iostream> header
followed by a using directive (using namespace std). So the following program will also compile, with
warning 890:
#include <iostream.h>
int main() {
cout << “Hello, World” << endl;
}
To turn off the warning, specify the +W890 command line option.
NOTE In general, you are encouraged to use header names as specified in the C++ standard. We do
not guarantee the inclusion of non-standard compliant headers in our future releases. See
the C++ international standard for detailed language rules.