|
Boost : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2000-11-13 15:47:09
Ed Brey wrote:
> Can we have the types put into a subnamespace so that they can be accessed
> without qualification after a statement such as:
> using namespace boost::int_types;
I have no objections.
> At one time boost used a pattern like this:
> namespace boost {
> namespace int_types {
> typedef char int8_t;
> }
> using namespace int_types;
> }
>
> However, I believe that this was found to break something, although I don't
> know what. (Anyone care to elaborate?)
Whatever reasons we come up with in this discussion, they should
be documented in the boost library guidelines so that we do not
repeat it time and again.
Here are a few thoughts about that:
- If the nested namespace contains class definitions, only the
nested namespace (and not all of boost) will be searched by
Koenig lookup.
- Assume the following use:
#include <cstdint.hpp>
// ...
void f()
{
using namespae boost::int_types;
int8_t x;
}
According to 7.3.4 [namespace.udir], the names from int_types
appear as if they were declared in the global namespace (!)
for unqualified lookup. This may cause unwanted ambiguities
(for the definition of 'x' in the example) if some other
header file includes the standard <stdint.h>, which defines
int8_t in the global namespace as well. This, of course,
results in similar C99 compatibility problems which we try to
avoid now.
What do others think?
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk