July 12, 2014
On 07/12/2014 12:38 PM, Danyal Zia wrote:

> You can initialize in constructor this(), but you can't initialize
> partial fields of struct when using pointer to struct.

Actually, that works too but members must be initialized from the beginning. The trailing ones are left with .init values:

struct S
{
    int i;
    string s;
}

void main()
{
    auto s = new S(42);
    static assert(is (typeof(s) == S*));
}

Ali

July 12, 2014
On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote:
> Actually, that works too but members must be initialized from the beginning. The trailing ones are left with .init values:
>
> struct S
> {
>     int i;
>     string s;
> }
>
> void main()
> {
>     auto s = new S(42);
>     static assert(is (typeof(s) == S*));
> }
>
> Ali

Ah, right. I still has C++ background in my veins I guess :)

1 2
Next ›   Last »