How can I pass a std::unique_ptr into a function? Lets say I have the following class:
std::unique_ptr
class A { public: A(int val) { _val = val
Since unique_ptr is for unique ownership, if you want to pass it as argument try
unique_ptr
MyFunc(move(ptr));
But after that the state of ptr in main will be nullptr.
ptr
main
nullptr