std::auto_ptr to std::unique_ptr
With the new standard coming (and parts already available in some compilers), the new type std::unique_ptr is supposed to be a replacement for … Read more
With the new standard coming (and parts already available in some compilers), the new type std::unique_ptr is supposed to be a replacement for … Read more
Why is there no std::make_unique function template in the standard C++11 library? I find std::unique_ptr<SomeUserDefinedType> p(new SomeUserDefinedType(1, 2, 3)); a bit verbose. Wouldn’t … Read more
I’m using the pimpl-idiom with std::unique_ptr: class window { window(const rectangle& rect); private: class window_impl; // defined elsewhere std::unique_ptr<window_impl> impl_; // won’t compile … Read more
What is wrong with this program? #include <memory> #include <vector> int main() { std::vector<std::unique_ptr<int>> vec; int x(1); std::unique_ptr<int> ptr2x(&x); vec.push_back(ptr2x); //This tiny command … Read more
I have some code in a header that looks like this: #include <memory> class Thing; class MyClass { std::unique_ptr< Thing > my_thing; }; … Read more
std::unique_ptr has support for arrays, for instance: std::unique_ptr<int[]> p(new int[10]); but is it needed? probably it is more convenient to use std::vector or … Read more
This question already has answers here: Closed 10 years ago. Possible Duplicates: pimpl: shared_ptr or unique_ptr smart pointers (boost) explained Could someone explain … Read more
unique_ptr<T> does not allow copy construction, instead it supports move semantics. Yet, I can return a unique_ptr<T> from a function and assign the … Read more
I’m new to move semantics in C++11 and I don’t know very well how to handle unique_ptr parameters in constructors or functions. Consider … Read more