The latest C++-standard (ISO-14882) requires that the standard
C++-library is defined in namespace std::. Thus, in order to use
classes from the standard C++-library, you can do one of three
things:
wrap your code in namespace std {
... } => This is not an option because only symbols
from the standard c++-library are defined in namespace std::.
put a kind of
using-declaration in your source (either
using namespace std; or i.e. using
std::string;) => works well for source-files, but
cannot be used in header-files.
use a fully qualified name for
each libstdc++-symbol (i.e. std::string,
std::cout) => can always be used
Because there are many compilers which still use an implementation
that does not have the standard C++-library in namespace
std::, some care is required to support these as
well.
Namespace back-portability-issues are generally not a problem with
g++, because versions of g++ that do not have libstdc++ in
std:: use -fno-honor-std
(ignore std::, :: = std::) by
default. That is, the responsibility for enabling or disabling
std:: is on the user; the maintainer does not have
to care about it. This probably applies to some other compilers as
well.
The following sections list some possible solutions to support compilers
that cannot ignore std::.
