I have an existing function:
void foo(const Key* key = nullptr)
{
// uses the key
}
I want to pass it pointer to temporary Key object (i.e. rvalue) like:
foo(&Key());
This causes compilation error, but is there a way in c++ 11/14 how I can do this? Of course I could do:
Key key;
foo(&key);
But I don't need object Key, I only need it inside foo() and foo()
Or I could do:
foo(new Key());
But then the object will not be deleted.