[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OFFTOPIC: How to use strings with libstdc++?

On Tue, Dec 29, 1998 at 08:21:43PM +0100, Wojciech Zabolotny wrote:
> Hi All
> I've stated that there is no old good String class in libstdc++.
> Instead I've found the "string" header which defines the "string" class.
> Is it OK to use it in new C++ programs, or it is added only for
> compatibility? Why has it such nonstandard name (without ".h" suffix).

>From Stroustrup:

=================Section B 3.1, third edition=============================
Traditionally, every header file had a .h suffix. Thus C++ implementations
provided headers such as <map.h> and <iostream.h>. For compatibiilty, most
still do.

When the standards committee needed headers for redefined versions of
standard libraries for newly added library facilities, naming those headers
became a problem. Using the old .h names would have caused compatibilty
problems. The solution was to drop the suffix .h in standard header names.
The suffix is redundant anyway because the <> notation indicates that a
standard header is being named.

Thus, the standard library provides non-suffixed headers, such as <iostream>
and <map>. The declarations in those fiels are placed in the namespace std.
Older headers place their declarations in the global namespace and use a .h

So, the decision is neither arbitrary nor non-standard. The only thing left
is to actually implement namespaces in gcc :)


"Rhubarb is no Egyptian god."        Debian GNU/Linux        finger brinkmd@ 
Marcus Brinkmann                   http://www.debian.org    master.debian.org
Marcus.Brinkmann@ruhr-uni-bochum.de                        for public  PGP Key
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       PGP Key ID 36E7CD09

Reply to: