Top "Unique-ptr" questions

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

How does the custom deleter of std::unique_ptr work?

According to N3290, std::unique_ptr accepts a deleter argument in its constructor. However, I can't get that to work …

c++ c++11 unique-ptr delete-operator
How to initialize std::unique_ptr in constructor?

A.hpp: class A { private: std::unique_ptr<std::ifstream> file; public: A(std::string filename); }; A.cpp: …

c++ smart-pointers ifstream unique-ptr
unique_ptr boost equivalent?

Is there some equivalent class for C++1x's std::unique_ptr in the boost libraries? The behavior I'm looking for …

c++ boost c++11 unique-ptr
what's the point of std::unique_ptr::get

Doesn't std::unique_ptr::get defeat the purpose of having a unique_ptr in the first place? I would have …

c++ c++11 pointers unique-ptr
Initializing a std::unique_ptr by passing the address of the pointer

I am creating a class which interops with some Windows API code, now one of the pointers I have to …

c++ c++11 unique-ptr
Forward declaration with unique_ptr?

I have found it useful to use forward declaration of classes in combination with std::unique_ptr as in the …

c++ destructor forward-declaration unique-ptr
Dynamic casting for unique_ptr

As it was the case in Boost, C++11 provides some functions for casting shared_ptr: std::static_pointer_cast std::…

c++ casting c++11 smart-pointers unique-ptr
How to capture a unique_ptr into a lambda expression?

I have tried the following: std::function<void ()> getAction(std::unique_ptr<MyClass> &&psomething){ //…

c++ lambda c++11 unique-ptr
How to perform a dynamic_cast with a unique_ptr?

I have a class hierarchy as follows: class BaseSession : public boost::enable_shared_from_this<BaseSession> class DerivedSessionA : …

c++ boost smart-pointers unique-ptr dynamic-cast
Passing unique_ptr to functions

I'm trying to "modernize" some existing code. I have a class which currently has a member variable "Device* device_". It …

c++ smart-pointers unique-ptr