Topic: Where does "string" class belong? (+ more on std namespace)
Author: Steve Clamage <stephen.clamage@sun.com>
Date: 2000/03/10 Raw View
Toralf Lund wrote:
>
> On egcs-c++-1.1.2-24 under Linux, it is globally visible, while it is
> declared within the "std" name space on IRIX/MipsPro C++. Which one is
> correct.
Almost everything in the C++ standard library is declared in namespace
std, and not in the global namespace. The exceptions are the various
forms of operator new and delete, and the declarations inherited from
C when you use the C form of the C standard headers. (That is,
if you include <stdio.h>, the declarations in that header are available
in the global namespace. If you include <cstdio> instead, the
declarations of types, objects, and functions are available only
in namespace std.)
>
> Actually, egcs has an "std" name space at all,
Assuming you meant to day "has no std namespace", that is the
explanation. It takes a while for all the standard features to
get incorporated into a C++ implementation. Evidently that version
of g++ is not up to date regarding namespaces.
--
Steve Clamage, stephen.clamage@sun.com
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Ari Lukumies <ari.lukumies@elmont.fi>
Date: 2000/03/10 Raw View
Toralf Lund wrote:
>
> On egcs-c++-1.1.2-24 under Linux, it is globally visible, while it is
> declared within the "std" name space on IRIX/MipsPro C++. Which one is
> correct.
Before namespaces were introduced, string (and others) were globally
visible; by the current standard they're in namespace std. So, the
latter follows the current standard and the former does not.
AriL
--
Pain and disappointment are inevitable. Misery is optional.
Homepaged at http://www.angelfire.com/or/lukumies
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Jason Nye" <jnye@nbnet.nb.ca>
Date: 2000/03/10 Raw View
The STL and string belong under the std namespace. G++ is catching up in
this respect, but is making great headway with their stdc++ efforts. You can
prefix all your strings, vectors with std:: as 'std' is #defined to be the
null string in g++. 'using namespace std' is also accepted in g++.
TIP: don't #define __STL_NO_NAMESPACES in your code -- this is used by the
particular implementation of the STL to help it compile on all platforms and
compilers. You should instead use 'using namespace std'.
Cheerio,
Jason
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Toralf Lund <toralf@kscanners.com>
Date: 2000/03/08 Raw View
On egcs-c++-1.1.2-24 under Linux, it is globally visible, while it is
declared within the "std" name space on IRIX/MipsPro C++. Which one is
correct.
Actually, egcs has an "std" name space at all, while it can be disabled
by defining the macro __STL_NO_NAMESPACES on IRIX. Can someone please
explain a bit more about name spaces in the context of STL and the
standard C++ library?
--
Toralf Lund <toralf@kscanners.no> +47 66 85 51 22
Kongsberg Scanners AS +47 66 85 51 00 (switchboard)
http://www.kscanners.no/~toralf +47 66 85 51 01 (fax)
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]