Struct constructor, opCall mess.
Remo
remo4d at gmail.com
Mon Feb 24 09:15:08 PST 2014
On Monday, 24 February 2014 at 14:14:43 UTC, Tobias Pankrath
wrote:
> On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote:
>> Hi,
>>
>> right now I am truing to figure out how the constructors
>> behave in D2.
>>
>> Question 1: why it is not possible to create custom ctor for
>> struct?
>
> The design of D relies on the fact that every type has a T.init
> property that is known to the compiler and used when in C++ the
> default ctor would get called. In constructors you can rely on
> (this == T.init), for example.
>
> You need to pick one T.init or default constructors and D
> picked T.init.
Well fortunately it seems to be possible to override init
property.
But it still does not called at struct construction.
http://melpon.org/wandbox/permlink/9EvcdzKUKoufqbJa
So what is proper/best way to mimic default constructor for
struct ?
More information about the Digitalmars-d-learn
mailing list