Re: Object Cast

2012-06-22 Thread Namespace
Seems to me that you achieved the your first purpose. Do you need more help? Kenji Hara I think i'm finished. Or have you any tip for me, related to the code?

Re: Object Cast

2012-06-21 Thread Kenji Hara
On Thursday, 21 June 2012 at 21:32:57 UTC, Namespace wrote: Works in dmd 2.059 too. Oh, good. [code] T template_cast(T : Object, U : Object)(U value) { // try to convert T val = cast(T) value; // if convert was successful, return if (val !is null) {

Re: Object Cast

2012-06-21 Thread Namespace
Works in dmd 2.059 too. [code] T template_cast(T : Object, U : Object)(U value) { // try to convert T val = cast(T) value; // if convert was successful, return if (val !is null) { return val; } // if cast fails it

Re: Object Cast

2012-06-21 Thread Kenji Hara
On Thursday, 21 June 2012 at 10:33:41 UTC, Namespace wrote: To solve the problem of converting a Object to a specific template class i wrote this little function. But the mixin disturbs me. How i can get the type (in this example Vector2D) without to mix a mixin and T.stringof? [code] T object

Object Cast

2012-06-21 Thread Namespace
To solve the problem of converting a Object to a specific template class i wrote this little function. But the mixin disturbs me. How i can get the type (in this example Vector2D) without to mix a mixin and T.stringof? [code] T object_cast(T : Object)(Object value) { T val = cast(T) val