On Monday, July 16, 2012 09:33:42 Namespace wrote: > Yes. I want a Pointer of Foo's reference, you're right. I think i > have to move the reference to the heap?
If you don't want it to point to a local variable and cause problems when it goes out of scope, then yeah, though I don't know if it's possible to do that or not. Probably, but I'd have to think about it and try out a bunch of stuff to be sure. Certainly, you could stick it in a struct and have a pointer to the struct. Regardless, I would point out that you lose polymorphism if you do that. You only get polymorphism with references, not pointers. So, you don't want to try and call member functions on a class instance through a pointer. But what you really should be using is std.typecons.Rebindable. If you're operating on pointers to class references much, then you're probably doing something wrong with your design. Classes really aren't intended to be used that way. - Jonathan M Davis