Boost logo

Boost :

From: Ed Brey (edbrey_at_[hidden])
Date: 2001-06-19 10:53:49

From: "David Abrahams" <david.abrahams_at_[hidden]>

> Hmm. I would much prefer, in that case, to see tuple directly in
> Subnamespaces should be for domain libraries (e.g. boost::python,
> boost::graph), as we have discussed earlier
> ( Tuples are not a
> but a utility.
> Wouldn't it be better for the user to write:
> using boost::tuple;
> than
> using namespace boost::tuple;
> no lookup issues; less typing.

The difficulty is that tuple is a bit like a domain, in that it involves
multiple names. For one name, I completely agree with the declaration
over the directive, but to use tuples, the user may well need:
    using boost::tuple;
    using boost::make_tuple;
    using boost::ignore;
    using boost::ref;
    using boost::cref;

The directive lets you pull in all the names at once. Since the number
of names is small, the chance of a name conflict is acceptably small,
even as the tuple library grows.

What are the lookup issues if the user (not the library) uses a

> > If the user don't perform such a using directive and the namespace
> > matches the class name, the code will have fragments like this:
> > "boost::tuple::tuple mytup" or at least "tuple::tuple mytup". This
> > isn't necessarily a problem: I use "string.string", "array.array",
> > "glob.glob" (although these are functions, not classes) in Python
> > without any confusion, but my experience in that regard is brief,
> > hence I was curious what more experienced users of non-unique names
> > found.
> I find that unconfusing and workable, but ugly. I like scopes to
narrow the
> domain as they are traversed, which string.string and glob.glob don't
> More importantly, scoping isn't buying you any protection in this
> "glob" is already taken at global scope, just like the name "tuple"
would be
> taken in namespace boost. Why make people reach in further just to
grab the
> piece they want?

Agreed. Of course, array and string are each just one of many names in
a namespace that exists for good reason; they just happen to have the
same as the namespace. Glob on the other hand definately seems
wasteful. Perhaps the authors were expecting to add more to the
namespace later.

> Or, I suppose, this would also work?
> namespace boost {
> namespace sub {
> class foo;
> }
> using sub::foo;
> }
> Anyway, that would be fine with me, if you want to do it.

Yes, also fine. The larger question, which is not tuple-specific at
all, is do we want to do this. It is a tradeoff of interface
minimalness versus convenience. Providing only the nested namespace
would seem best if a reasonably convenient usage pattern for end users
can be found.

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