Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-09-01 14:34:46


On August 17th, Ed Brey wrote:

>I can see it being convenient to pull all the integer types into the
>current namespace in one operation. To that end, I'd like to
propose
>that cstdint.hpp change to look like this:
>
>#ifndef BOOST_CSTDINT_HPP
>#define BOOST_CSTDINT_HPP
>
>namespace boost
>{
>
>namespace integer_types
>{
>#include <boost/stdint.h>
>}
>
>using namespace integer_types;
>
>} // namespace boost
>
>#endif // BOOST_CSTDINT_HPP
>
>
>
>This would allow a particular function to do something like this:
>
>void fn()
>{
> using namespace boost::integer_types;
>
> int_least8_t var1;
> uint32 var2;
> ...
>}
>
>In general, I think this kind of sectioning would be useful for
>groups of related names that show up in "utility" libraries like
>cstdint.hpp.

I tried this "nested namespace with namespace scope using directive"
technique several times in the last two weeks, including in
http://www.boost.org/boost/cast.hpp.

My overall reaction is quite positive. In addition to the "using
namespace boost::integer_types;" usage you mention, it also allows
the other usual ways to specify namespace, and is quite transparent
to those who want to never/always use global scope using directives.

The one problem I had is that it tends to break compilers,
particularly when combined with templates. That will pass with time,
but it was discouraging to try the technique with the boost integer
library and find all four compilers I use barfing on one test or
another. Of course, several were failing to start with.

My conclusion is to go ahead with it, but slowly until more compilers
improve. It is too messy to charge ahead now, and then have to put
in a lot of conditionals to get it to work with everyday compilers.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk