"Value class instance" pattern?

bearophile bearophileHUGS at lycos.com
Sun Jul 14 05:03:45 PDT 2013


Benjamin Thaut:

> I just noticed that this still does not work. Even with dmd 
> 2.063 I get the error message:
>
> main.d(28): Error: template 
> main.ComposeClass!(Object).ComposeClass.__ctor(Targs...)(Targs 
> args) conflicts with constructor 
> main.ComposeClass!(Object).ComposeClass.this at main.d(20)
>
> If you have a templated constructor you can't have any non 
> templated constructors. 
> (http://d.puremagic.com/issues/show_bug.cgi?id=4749)
> So a version with a templated constructor is still not doable 
> at the moment.

Sorry, I forgot to say that I am using this:

     this()(UseDefaultCtor) {
         classInstanceBuf[] = typeid(T).init[];
         _instance.__ctor;
     }

Bye,
bearophile


More information about the Digitalmars-d mailing list