C++ Logo

sg20

Advanced search

Re: namespace composition

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 29 Apr 2023 03:55:38 +0300
On Sat, 29 Apr 2023 at 03:40, Bjarne Stroustrup <bjarne_at_[hidden]> wrote:
> > Name lookup in C++ is complicated. :P
> Too complicated, and there is probably little we can do about it.

Right, but we would curse the language if it just allowed what you're
trying to do, when programming at scale(*). You have
an altruistic hack here, but it's still a hack. You're trying to take
everything that's in std, but sneak
in an alternative for vector, with slightly different semantics. The
language quite reasonably says "Whoa. If you
want that, establish a new namespace where you can decide what the
rules are, but no such sneaking under
my watch." And it does the same if you attempt to sneak in via another
route, by doing a using-directive of PPP
and then using unqualified names. The language says "I told you this
is not okay, don't try to dance around that."

(*) I mean, imagine working on a large project, getting puzzled why
your vectors don't seem to work as expected,
and then finding out a sneak-in. You would curse. You would think that
the language shouldn't allow such
sneaking to occur.

Received on 2023-04-29 00:55:51