extern(C++, ns)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 20 14:13:09 PST 2016


On 1/20/2016 4:47 AM, Manu via Digitalmars-d wrote:
> As a bonus, the project's C++ namespace 'libname' is already present
> in the fully qualified name, it's the top level package! No point
> repeating that as 'libname.feature.libname.symbol'.

You can always write a module that all it does is import a bunch of other 
modules, with a bunch of aliases which can be used to make those imports appear 
in another namespace:

    ----module core.stdcpp.vector----
    extern (C++, std) { struct vector { } }

    ----module core.stdcpp.string----
    extern (C++, std) { struct string { } }

    ----module stl------
    private import core.stdcpp.vector;
    private import core.stdcpp.string;
    ...
    extern (C++, std)
    {
       alias core.stdcpp.vector.std.vector vector;
       alias core.stdcpp.string.std.string string;
       ...
    }

    ---module user-----
    import stl;

    std.vector v;
    std.string s;




More information about the Digitalmars-d mailing list