In order to pass a temporary object to the function, it must take the argument either by value or by constant reference. Non-constant references to temporary objects aren't allowed. So either of the following should work:
void someFunc(const Ref&);
someFunc(Ref(Foo)); // OK, constant reference to temporary
void someFunc(Ref);
someFunc(Ref(Foo)); // OK, copy of temporary
void someFunc(Ref&);
someFunc(Ref(Foo)); // Invalid, non-constant reference to temporary
Ref ref(Foo);
someFunc(ref); // OK, non-constant reference to named object
By the way, calling the type Ref
and the instance pointer
when it's neither a reference nor a pointer could be a bit confusing.