Specifying C++ symbols in C++ namespaces
Tove
tove at fransson.se
Sat Apr 5 14:31:24 PDT 2014
On Saturday, 5 April 2014 at 20:47:29 UTC, Walter Bright wrote:
> On 4/2/2014 3:07 PM, Walter Bright wrote:
>> One downside of this proposal is that if we ever (perish the
>> thought!) attempted
>> to interface to C++ templates, this design would preclude that.
>
> Yes, this seems to be a fatal flaw. Another design that has
> evolved from these discussions and my discussions with Andrei
> on it:
>
> extern (C++, namespace = A.B) { void foo(); void bar(); }
> extern (C++, namespace = C) void foo();
>
> bar(); // works
> A.B.bar(); // works
> foo(); // error: ambiguous
> C.foo(); // works
>
> alias C.foo foo;
> foo(); // works, calling C.foo()
>
> I really think the namespace semantics should be attached to
> the extern(C++) rather than be a separate pragma. Having the
> namespace= thing means that namespace isn't a keyword, and
> provides a general mechanism where we can add language specific
> information as necessary.
How could this common pattern look?
std::string
boost::fun(std::string arg)
alias cpp = extern (C++, namespace = std);
alias boost = extern (C++, namespace = boost);
cpp.string
boost.fun(cpp.string arg)
?
More information about the Digitalmars-d
mailing list