On Tuesday, 22 September 2015 at 04:07:54 UTC, Ola Fosheim Grostad wrote:
On Tuesday, 22 September 2015 at 00:31:45 UTC, Paul O'Neil wrote:
While D and C++ const don't quite share semantics, they're petty close and they mangle the same way. I do what ZombieDev has in the table.

Going from const to mutable like that breaks the type system...


Can pragma(mangle, ...) be used on types? Then we can define a C/C++ compatible `HeadConst` template that simulates C/C++ const semantics, while still being mangled correctly:

template HeadConst(T) {
    pragma(mangle, const(T).mangleof)
    struct HeadConst {
        // @disable opAssign();
        // and whatever else is necessary for head-const
    }
}

The constructor would of course need to make sure that it accepts only types with non-const indirection.

Reply via email to