Category "unique-ptr"

stoi out ouf range exception when reusing unique ptr

I'm trying to transmitt a draco encoded point cloud via socket.io. In the first iteration everything is fine but in every following iteration abort() is being c

How to avoid the need to specify deleter for std::shared_ptr every time it's constructed or reset?

std::unique_ptr has 2 template parameters, the second of which is the deleter to be used. Thanks to this fact, one can easily alias a unique_ptr to a type, whic

Is it safe to init a std::unique_ptr from a local raw pointer?

I know it's unwise to do so with a std::shared_ptr. But what about std::unique_ptr? E.g. : class A { public: void do_something() { } }; std::vector<std::

Basic forward list using unique_ptrs

As an exercise in learning C++, I want to build my own forward list using raw pointers and using unique_ptrs. Using raw pointers, I have: struct node_raw {

Why can't a weak_ptr be constructed from a unique_ptr?

If I understand correctly, a weak_ptr doesn't increment the reference count of the managed object, therefore it doesn't represent ownership. It simply lets you

How do I use a custom deleter with a std::unique_ptr member?

I have a class with a unique_ptr member. class Foo { private: std::unique_ptr<Bar> bar; ... }; The Bar is a third party class that has a create