tail const

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Dec 3 19:23:45 PST 2010


On 12/3/10 7:40 PM, Michel Fortin wrote:
> I have an idea that would fix those: make a template struct/class
> instance implicitly convertible to another instance of that same
> template if all members share the same memory layout and each member is
> implicitly convertible to the same member of the other template.

I'm afraid that can't work.

struct A(T) {
     T obj;
     void fun() { obj->method(); }
}

auto a = new A!Widget;
a.obj = new Widget;
A!Object b = a; // works because Widget converts to Object
b.obj = new Object; // ummmm...
b.fun(); // ummmm...


Andrei


More information about the Digitalmars-d mailing list