unique-ptr
C++11 Pointer Uniquify Helper Function
In C++11, I\'m missing a syntatic sugar for uniquifying a pointer into std::unique_ptr. I therefore wrote the following litte helper function 开发者_开发技巧std::uniquify_ptr typically used to easy (n[详细]
2023-04-10 15:25 分类:问答C++ how to sort dynamically using lambda functions for a vector of unique_ptrs?
So I have a std::vector<std::unique_ptr<Base>> vec and I\'m trying to sort it dynamically, given that there are logical comparisons between Derived1 to Derivedn (Derivedn always > Derivedn[详细]
2023-04-06 09:31 分类:问答How to remove unique_ptr by pointer from a container?
Creating an object and giving ownership to a container using a unique_ptr is no problem. How would one remove an element by raw pointer?[详细]
2023-03-24 05:05 分类:问答Differences between unique_ptr and shared_ptr [duplicate]
This question already has answers here: Closed 11 years ago. Possible Duplicates: pimpl: shared_ptr or unique_ptr[详细]
2023-03-24 01:23 分类:问答STL rotating const_iterators of unique_ptrs
I have problems using std::rotate on a const_iterator over a unique_ptr middle. I have tried: std::vector<std::unique_ptr<Object> >::const_iterator middle;[详细]
2023-03-21 06:28 分类:问答unique_ptr custom storage type example?
Howard Hinnant explained that unique_ptr can also use a custom storage type. He mentions as an example \"shared memory\".[详细]
2023-03-11 09:50 分类:问答What is the scope of a unique_ptr returned from a function?
Would this work properly? (see example) unique_ptr<A> source() { 开发者_开发百科return unique_ptr<A>(new A);[详细]
2023-03-07 15:30 分类:问答Is std::unique_ptr<T> required to know the full definition of T?
I have some code in a header that looks like this: #include <memory> class Thing; class MyClass { std::unique_ptr< Thing > my_thing;[详细]
2023-03-05 22:14 分类:问答function that modifies object pointed to by std::unique_ptr<T>
Somewhere in my code I have a local std::unique_ptr<T>. I need to do stuff with the object pointed at, and I use a function for that:[详细]
2023-03-04 05:15 分类:问答pimpl: Avoiding pointer to pointer with pimpl
In this question I asked \"pimpl: shared_ptr or unique_ptr\" I\'ve been convinced that the proper usage of the pimpl idiom is to use a unique_ptr, not a shared_ptr. It should act to the user as if the[详细]
2023-02-23 05:34 分类:问答