digitalmars.D.learn - TypeInfo manipulation
- Zhenya (10/10) Oct 25 2012 Hi!
- Zhenya (2/12) Oct 26 2012 Or maybe there are a possibility to parametrize class by TypeInfo?
- Zhenya (2/16) Oct 27 2012 Is my question is so meaningless, that no one even say why? :(
- Maxim Fomin (5/19) Oct 27 2012 What do you mean: "to parametrize class by Typeinfo"?
- Maxim Fomin (4/14) Oct 27 2012 I can barely understand what exactly you were doing. If you post
Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried to write some smart pointer that overlad classinfo property in accordance with the real type of hold object,but I failed to do this becouse of not having possibility to declar static and non-static version of the one function.Maybe there are better ways to do this?
Oct 25 2012
On Thursday, 25 October 2012 at 15:05:05 UTC, Zhenya wrote:Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried to write some smart pointer that overlad classinfo property in accordance with the real type of hold object,but I failed to do this becouse of not having possibility to declar static and non-static version of the one function.Maybe there are better ways to do this?Or maybe there are a possibility to parametrize class by TypeInfo?
Oct 26 2012
On Friday, 26 October 2012 at 19:57:14 UTC, Zhenya wrote:On Thursday, 25 October 2012 at 15:05:05 UTC, Zhenya wrote:Is my question is so meaningless, that no one even say why? :(Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried to write some smart pointer that overlad classinfo property in accordance with the real type of hold object,but I failed to do this becouse of not having possibility to declar static and non-static version of the one function.Maybe there are better ways to do this?Or maybe there are a possibility to parametrize class by TypeInfo?
Oct 27 2012
On Friday, 26 October 2012 at 19:57:14 UTC, Zhenya wrote:On Thursday, 25 October 2012 at 15:05:05 UTC, Zhenya wrote:What do you mean: "to parametrize class by Typeinfo"? class A { } A!TypeInfo var; If you mean this, than how it can help?Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried to write some smart pointer that overlad classinfo property in accordance with the real type of hold object,but I failed to do this becouse of not having possibility to declar static and non-static version of the one function.Maybe there are better ways to do this?Or maybe there are a possibility to parametrize class by TypeInfo?
Oct 27 2012
What do you mean: "to parametrize class by Typeinfo"? class A { } A!TypeInfo var; If you mean this, than how it can help?It would be well if I could create object that inherits class with this typeinfo.
Oct 27 2012
I have double dispatcher: template Dispatcher(R) { R execute(Left,Right)(R delegate(Left,Right) f,Object left,Object right) { return f(cast(Left)left,cast(Right)right); } struct Dispatcher { private R delegate(Object,Object)[Tuple!(TypeInfo_Class,TypeInfo_Class)] m_callbacks; void add(Left,Right)(R delegate(Left,Right) f) { m_callbacks[tuple(Left.classinfo,Right.classinfo)] = (Object l,Object r){return execute!(Left,Right)(f,l,r);}; } void remove(Left,Right)() { m_callbacks.remove(tuple(Left.classinfo,Right.classinfo)); } R opCall(Object l,Object r) { R delegate(Object,Object)* callback = tuple(l.classinfo,r.classinfo) in m_callbacks; return (*callback)(l,r); } } } And I have some class ierarhy: class GameObject { } class Foo : GameObject { } class Bar : GameObject { } problem is to create some wrapper to this classes struct GameHandle(Type) and this code work void main() { Dispatcher!void d; d.add!(GameHandle!Foo,GameHandle!Bar)((GameHandle!Foo,GameHandle!Bar){writeln("haha");}); GameHandle!GameObject a;a.m_hold = new Foo; GameHandle!GameObject b;b.m_hold = new Bar; d(a,c); readln(); }
Oct 27 2012
On Thursday, 25 October 2012 at 15:05:05 UTC, Zhenya wrote:Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that?It is impossible to overload typeid typeinfo.Some time ago I tried to write some smart pointer that overlad classinfo property in accordance with the real type of hold object,but I failed to do this becouse of not having possibility to declar static and non-static version of the one function.Maybe there are better ways to do this?I can barely understand what exactly you were doing. If you post some code example it will probably help to find solution.
Oct 27 2012