Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-09-06 09:42:32

----- Original Message -----
From: John Maddock <John_Maddock_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, September 06, 2001 7:50 AM
Subject: RE: [boost] aligned_storage<> and optional<>

> >You might want to add in your document, as an alternative workaround -a
> lot
> >harder though-, the non-type to type transformation I applied. It allows
> you
> >to retain the 'defaul't parameter, which might be necesary..
> Do you want to write it up and add to the text?
Yes I want to. I'll see to do it tonight.

> >some_user.cpp:
> >~~~~~~~~~~
> >
> >namespace ConflictingLibrary {
> > #include "some_header.h"
> >}
> >
> >This won't compile since A is not in the global namespace anymore.
> >
> That's really seriously nasty, I can see why you might try to do that, but
> you really shouldn't. Seriously - all kinds of things might break in a
> case like that.
Yes your are right, I shouldn't (And I won't, but I'm worry about what
others users might do)

We should *forbid* the user from putting boost in anything but the global
namespace, and this should go in the documentation, perhaps in the 'download
and installation' section.

We could use the following trap to make sure the user obeys with the above:

struct boost_should_be_in_the_global_namespace {} ;
using ::boost_should_be_in_the_global_namespace ;

This won't compile if it isn't in the global namespace.

If you agree, I will add to the text that: (with more or less this wording)

This technique uses the 'global access modifier', which requires the
identifier to be in the global namespace.
The user must not be allowed to include any header which uses this idiom in
another namespace.
The recommended practice is that the user of a given library is supposed to
put the library ONLY in the global namespace, so that the library itself can
define the namespaces it uses w.r.t to the global namespace.
In the case of the boost library, this is already a requirement.
If you are using this idiom in your own library, you can make sure it is in
the global namespace using the following trap:

struct LIBRARY_should_be_in_the_global_namespace {} ;
using ::LIBRARY_should_be_in_the_global_namespace ;

Fernando Cacciola
Sierra s.r.l.

Boost list run by bdawes at, gregod at, cpdaniel at, john at