Re: Struct ctor called with cast

2018-02-27 Thread Radu via Digitalmars-d-learn
On Tuesday, 27 February 2018 at 21:04:59 UTC, ag0aep6g wrote: On 02/27/2018 09:59 PM, Radu wrote: On Tuesday, 27 February 2018 at 20:51:25 UTC, ag0aep6g wrote: On 02/27/2018 09:30 PM, Radu wrote: [...] [...] [...] So the bug is that somehow the templated version makes it so there is an impl

Re: Struct ctor called with cast

2018-02-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/27/18 3:59 PM, Radu wrote: On Tuesday, 27 February 2018 at 20:51:25 UTC, ag0aep6g wrote: On 02/27/2018 09:30 PM, Radu wrote: enum Type { a }; struct S(Type t = Type.a) { this(Type)(Type t) { import std.stdio; writeln("ctor called."); } } void main() {    

Re: Struct ctor called with cast

2018-02-27 Thread ag0aep6g via Digitalmars-d-learn
On 02/27/2018 09:59 PM, Radu wrote: On Tuesday, 27 February 2018 at 20:51:25 UTC, ag0aep6g wrote: On 02/27/2018 09:30 PM, Radu wrote: [...] enum Type { a }; struct S(Type t = Type.a) { this(Type)(Type t) { import std.stdio; writeln("ctor called."); } } [...] S

Re: Struct ctor called with cast

2018-02-27 Thread Radu via Digitalmars-d-learn
On Tuesday, 27 February 2018 at 20:51:25 UTC, ag0aep6g wrote: On 02/27/2018 09:30 PM, Radu wrote: enum Type { a }; struct S(Type t = Type.a) {     this(Type)(Type t)     {     import std.stdio;     writeln("ctor called.");     } } void main() {    auto x = S!(Type.a)(Type.a);   

Re: Struct ctor called with cast

2018-02-27 Thread ag0aep6g via Digitalmars-d-learn
On 02/27/2018 09:30 PM, Radu wrote: enum Type { a }; struct S(Type t = Type.a) {     this(Type)(Type t)     {     import std.stdio;     writeln("ctor called.");     } } void main() {    auto x = S!(Type.a)(Type.a);    void* y = &x;    auto z = (cast(S!(Type.a)) y); } Surpris

Struct ctor called with cast

2018-02-27 Thread Radu via Digitalmars-d-learn
I have this: enum Type { a }; struct S(Type t = Type.a) { this(Type)(Type t) { import std.stdio; writeln("ctor called."); } } void main() { auto x = S!(Type.a)(Type.a); void* y = &x; auto z = (cast(S!(Type.a)) y); } Surprisingly the cast will actually c