Re: Template this parameter in constructor

2016-02-26 Thread Vlad Leberstein via Digitalmars-d-learn
On Sunday, 21 February 2016 at 21:48:21 UTC, Steven Schveighoffer wrote: This isn't a bug. Here is what happens. 1. template this is assigned the compile-time type of the object *when the function is called*. 2. A base class constructor is called from the next derived constructor. So C2's

Template this parameter in constructor

2016-02-21 Thread Vlad Leberstein via Digitalmars-d-learn
Hi! I'm struggling to use "Template This Parameters" feature(as described in https://dlang.org/spec/template.html#TemplateThisParameter) in class constructor. But it's usage isn't documented very clearly and I'm not even sure if it's supposed to work this way. Consider the following example:

Re: Variant and immutable struct

2016-01-10 Thread Vlad Leberstein via Digitalmars-d-learn
Okay, I've cleared up some misconception. On Wednesday, 6 January 2016 at 03:22:47 UTC, Vlad Leberstein wrote: The same happens with immutable class(there is related thread with workaround at

Variant and immutable struct

2016-01-05 Thread Vlad Leberstein via Digitalmars-d-learn
Hi! I've stumbled into some strange problem. I'm trying to put an immutable struct into std.variant.Variant but get some compilation error(but only when struct has at least one member). Stripped down example(tested on Linux dmd64 v2.069.2): import std.variant : Variant; immutable struct

Problem with casting instance reference to void* and back.

2015-07-27 Thread Vlad Leberstein via Digitalmars-d-learn
Hi! My use case requires interaction with C API which in turn implies storing object instance reference as void *. I'm using gdc 4.9.2 and everything worked fine with object - void * - object conversion, but object - void * - interface failed. The stripped-down example is something like this:

Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread Vlad Leberstein via Digitalmars-d-learn
auto self = cast(TestInterface)cast(Object) rawSelf Works like a charm! Thank you both!