Say I have an initialised object Foo_obj
of a class Foo
and wish to create a unique smart pointer to a copy of this object. The code auto pointer = make_unique<Foo>(Foo_obj)
executes and does exactly this. However when looking at the reference for std::make_unique
, this only accepts R-value references as arguments and calls the constructor of the respective class with these arguments.
My understanding is that an object such as Foo_obj
is an l-value and thus the above code should not compile. What am I missing?