Top "Unique-ptr" questions

std::unique_ptr is a smart pointer that retains sole ownership of an object through a pointer.

Should I use shared_ptr or unique_ptr?

I have a question about std::unique_ptr and std::shared_ptr. I know there are loads of questions about …

c++ c++11 shared-ptr smart-pointers unique-ptr
Why am I allowed to copy unique_ptr?

Possible Duplicate: Returning unique_ptr from functions 20.7.1.2 [unique.ptr.single] defines copy constructor like this : // disable copy from lvalue unique_…

c++ g++ c++11 unique-ptr
Use unique_ptr for ownership and raw pointer otherwise?

I am C++11-ing some code. I have class X { /* */ }; class A { std::vector<X*> va_x; }; class …

c++ c++11 unique-ptr ownership
remove unique_ptr from queue

I'm trying to figure out how/if I can use unique_ptr in a queue. // create queue std::queue<…

c++ c++11 unique-ptr
Why is shared_ptr<void> legal, while unique_ptr<void> is ill-formed?

The question really fits in the title: I am curious to know what is the technical reason for this difference, …

c++ shared-ptr smart-pointers unique-ptr
Calling initializer_list constructor via make_unique/make_shared

I'm trying to use std::make_unique to instanciate a class whose constructor is to receive an std::initializer_list. …

c++ unique-ptr c++14 initializer-list
shared_ptr<> is to weak_ptr<> as unique_ptr<> is to... what?

In C++11, you can use a shared_ptr<> to establish an ownership relation with an object or variable …

c++ c++11 unique-ptr
Why is "error: invalid application of 'sizeof' to an incomplete type using unique_ptr" fixed by adding an empty destructor?

I am Pimpling off the class STFT. Compiles just fine with this in the header: class STFT; // pimpl off to …

c++ c++11 unique-ptr pimpl-idiom
Lock-free swap of two unique_ptr<T>

Swapping two unique_ptrs is not guaranteed to be threadsafe. std::unique_ptr<T> a, b; std::swap(…

c++ c++11 unique-ptr lock-free atomic-swap