|
Boost : |
From: John Maddock (John_Maddock_at_[hidden])
Date: 1999-10-10 05:59:36
Dave -
> On the other hand we could use:
>
> #include <cstdlib>
>
> namespace boost{
> namespace undocumented{
>
> #ifdef BOOST_NO_STDC_NAMESPACE
> using ::size_t;
> #else
> using std::size_t;
> #endif
>
> /* code goes here */
>
> } // namespace undocumented
> using boost::undocumented::some_public_symbol;
> } // namespace boost
>Why bother with this using declaration at all?
With it you still have the same drawback you described above if the user
writes 'using namespace boost' (which, by the way, I don't believe we
should
go out of our way to make safe -- since that's well nigh impossible).<
The point with this method is that only documented symbols are in visible
in namespace boost - everything that's private to the implementation (and
undocumented) - whether helper classes, typedefs or using declarations -
remains in namespace boost::undocumented and is *not* imported into
namespace boost, or into the global namespace if there is a "using
namespace boost" declaration. This is what I meant in this case by
"implementation hiding" - only documented types should be present in
namespace boost - anything else can be hidden away in a private namespace.
BTW the standard more or less mandates this for namespace std - including a
particular header should declare only types documented for that header in
namespace std - anything else (implementation details) should not be in
std. At least that's my reading on this :-)
However we've gotten off topic, I still think that the original suggestion
- importing global symbols into namespace std for VC6 is the right way to
go.
- John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk