Struct ctor called with cast

Radu void at null.pt
Tue Feb 27 21:14:26 UTC 2018


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 implicit void* ctor.
>
> In your original code (quoted above), you've got a templated 
> constructor. The `Type` in `this(Type)(Type t)` is not the 
> enum. It's a template parameter of the constructor.
>
> To get a non-templated constructor that takes a `Type` (the 
> enum), you have to write:
>
> ----
> this(Type t) /* NOTE: Only one set of parentheses. */
> {
>     /* ... */
> }
> ----

Understood, make sense now, thanks!


More information about the Digitalmars-d-learn mailing list