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.