Is there other way to do that?

2021-02-14 Thread Jack via Digitalmars-d-learn
I need to check if an instance is of a specific type derived from my base class but this class has template parameter and this type isn't available at time I'm checking it. Something like: class B { } class A(T) : B { } class X : B { } class Z : B { } auto c = can be any derived class from B b

Re: Constructor called instead of opAssign()

2021-02-14 Thread frame via Digitalmars-d-learn
On Sunday, 14 February 2021 at 08:38:49 UTC, Boris Carvajal wrote: On Sunday, 14 February 2021 at 07:09:20 UTC, frame wrote: Although x is well initialized by A by calling opAssign(), the compiler doesn't care and calls the S!T ctor() on B again and opAssign() is ignored. Is this a bug or a rul

Re: Constructor called instead of opAssign()

2021-02-14 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 February 2021 at 07:09:20 UTC, frame wrote: Although x is well initialized by A by calling opAssign(), the compiler doesn't care and calls the S!T ctor() on B again and opAssign() is ignored. Is this a bug or a rule? It's a rule described here: https://dlang.org/spec/struct.html