Struct constructor, opCall mess.
Remo
remo4d at gmail.com
Mon Feb 24 05:56:00 PST 2014
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?
I know this is not really necessary because you can initialize
fields like this.
struct S{ int i = 1; }
But this is a big problem if one tries to port C++ code to D2 and
default ctor call some important initialization code.
Question 2: is there a way to mimic compiler generated ctor (that
work in CTFE)?
Question 3: why it is possible to call static opCall like this?
VectorC v5 = v4(1.0);
Right now opCall seems to be better as this(...) because it work
in CTFE but because of unwanted calls this is not well at all.
Question 4: why this(...) does not work in CTFE mode?
Here is highly simplified test code.
http://melpon.org/wandbox/permlink/ofvNby99mKqOBQBf
I am asking this because I am learning D2 now by porting and
warping/connecting some big C++ (C++11) project to D2.
More information about the Digitalmars-d-learn
mailing list