Re: How to convert these constructs to D?

2013-12-01 Thread Kozzi
I'm basically porting all the mysql-client headers which i thought would be pretty straight forward but it's taking a little more thought than i anticipated. Can I ask why? And the part of code you are asking is from pthread headers not from mysql.

Re: Understanding opAssign and 'alias this'

2013-10-13 Thread Kozzi
On Sunday, 13 October 2013 at 21:37:31 UTC, Maurice wrote: Hello, Can anybody explain my what is happening here? enum xxx = true; struct A { static if (xxx) ref A opAssign(ref const A a) { return this; } ref A opAssign(int v) { return this; } } struct B { A a;

Re: Support implicit conversion between types

2013-09-04 Thread Kozzi
So you can use templates, something like this: bool isConvertableToFoo(T) { T i = void; return is(typeof(Foo(i)) == Foo); } void bar(T)(T i) if (is(T : Foo)) { //some code } void bar(T)(T i) if (!is(T : Foo) && isConvertableToFoo!T) { bar(Foo(i)); } I do not test it so it is