digitalmars.D.learn - pointers, null and Typedef...
- John Colvin (41/41) Aug 23 2013 so, here's the situation:
- Paolo Invernizzi (21/22) Aug 23 2013 On 2.063.2 why not something like this:
- John Colvin (3/25) Aug 24 2013 It's const(void*) not just void*
- Paolo Invernizzi (3/11) Aug 24 2013 Sorry John, you are right, naturally.
so, here's the situation: current old code has: typedef const(void*) T0, T1; which is of course deprecated. context that needs to work: struct A { T0 t; this(T0 init) { t = init; } } Also, I need type-safety. is(T0 == T1) *must* be false. I have a modified Typedef I'm using to get things started, allowing Typedef!(const(void*), const(void*).init, "T0") to work at all: struct Typedef(T, T init = T.init, string cookie=null) { static if(init != T.init) { private T Typedef_payload = init; } else { private T Typedef_payload; } this(T initial) { Typedef_payload = initial; } this(typeof(this) initial) { Typedef_payload = initial.Typedef_payload; } mixin Proxy!(Typedef_payload); } but that doesn't get me all of the way, there's still no way I can see to get the t = init to work. I wish there was some way to call a constructor on a object after it is declared (perhaps with the same rules as const initialisation?).
Aug 23 2013
On Friday, 23 August 2013 at 12:17:08 UTC, John Colvin wrote:so, here's the situation:On 2.063.2 why not something like this: --- import std.typecons; alias T0 = Typedef!(void*, null, "T0"); alias T1 = Typedef!(void*, null, "T1"); static assert( ! is(T0 == T1)); struct A { T0 t; this(T0 init) { t = init; } } void foo(){ auto a = A(T0(null)); // auto b = A(T1(null)); Error! } --- Paolo
Aug 23 2013
On Friday, 23 August 2013 at 18:58:49 UTC, Paolo Invernizzi wrote:On Friday, 23 August 2013 at 12:17:08 UTC, John Colvin wrote:It's const(void*) not just void* Unfortunately that breaks it.so, here's the situation:On 2.063.2 why not something like this: --- import std.typecons; alias T0 = Typedef!(void*, null, "T0"); alias T1 = Typedef!(void*, null, "T1"); static assert( ! is(T0 == T1)); struct A { T0 t; this(T0 init) { t = init; } } void foo(){ auto a = A(T0(null)); // auto b = A(T1(null)); Error! } --- Paolo
Aug 24 2013
On Saturday, 24 August 2013 at 09:19:14 UTC, John Colvin wrote:On Friday, 23 August 2013 at 18:58:49 UTC, Paolo Invernizzi wrote:Sorry John, you are right, naturally. - PaoloOn Friday, 23 August 2013 at 12:17:08 UTC, John Colvin wrote:It's const(void*) not just void* Unfortunately that breaks it.so, here's the situation:On 2.063.2 why not something like this:
Aug 24 2013