I have this struct: enum AddrType { Abs, RVA, Rel }; struct Address { shared_ptr<DWORD> addr; AddrType type;
Address(): type(Abs) {} Address(DWORD addr, AddrType type): addr(shared_ptr<DWORD>(new DWORD(addr))), type(type) {} Address(shared_ptr<DWORD> addr, AddrType type): addr(addr), type(type) {} Address(const Address &ad): addr(ad.addr), type(ad.type) {} }; My problem is with default alue init... Address(): type(Abs) {} Address(DWORD addr, AddrType type): addr(shared_ptr<DWORD>(new DWORD(addr))), type(type) {} How to make this in D ? I do this: struct Address { RefCounted!(DWORD) addr; AddrType type = AddrType.Abs; this(DWORD addr, AddrType type) { addr(RefCounted!(DWORD)(new DWORD(addr))); this.type = type; } /*Address(shared_ptr<DWORD> addr, AddrType type) : addr(addr), type(type) {} Address(const Address &ad) : addr(ad.addr), type(ad.type) {}*/ }; It's correct ? In case for a template, when I have this: template <typename T> struct Wrap { T val; Wrap(T val): val(val) {} }; I maded this: template Wrap(T) { struct Wrap { T val; this(T val){val = val;} } } PS: ( I know about identation... it's wrong here... )