Is there any good reason why C++ namespaces are "closed" in D?
rikki cattermole
rikki at cattermole.co.nz
Thu Aug 2 12:30:14 UTC 2018
On 03/08/2018 12:24 AM, Steven Schveighoffer wrote:
> The example that Walter keeps bringing up is one where the C++ code has
> 2 namespaces in the same header file. Not only that, but then
> identically named functions in those namespaces. In that case, a direct
> translation would cause problems with hijacking in D, where it doesn't
> in C++ (as long as you don't ever use `using` declarations, or only use
> one or the other).
>
> So the difference from your example is that you're not trying to bind 2
> different files with 2 different namespaces into one D module, but you
> are translating a single C++ header file that's written with the 2
> bindings as described. Not std and boost, but ns1 and ns2 inside the
> same header file, which each have identical symbols.
>
> I've never seen it, but it's certainly valid C++ and in the realm of
> possibility.
>
> -Steve
That's easy to solve.
Split into a package, public import each file and alias if required to
get each version.
It's easy to work around and most importantly, reasonable.
More information about the Digitalmars-d
mailing list