On Monday, July 16, 2012 00:47:27 Namespace wrote: > Is something like this possible? > > Foo* create_ptr(Foo f) { > assert(f !is null); > // ... > } > > Foo* fp = create_ptr(new Foo()); > > with "ref Foo f" of course, there is no limitation.
You cannot have pointers to classes. The language does not support it. You can have pointers to class references, and you can have pointers to structs or the built-in types, but if Foo is a class, then what you can't have a pointer to it. The closest that you can get is that I believe that you can cast class references to and from void*, and that will work, but Foo* is a pointer to a reference to Foo, not a pointer to Foo, and there's no way in the type system to represent a pointer to Foo. - Jonathan M Davis