IT Nursery
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 std::auto_ptr. Does their usage exactly overlap...
  • May 31, 2022
  • 0 Comments
IT Nursery
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 the following be much nicer? auto...
  • May 26, 2022
  • 0 Comments
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 }; However, I get a compile...
  • May 23, 2022
  • 0 Comments
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 has a vicious error. return 0;...
  • May 21, 2022
  • 0 Comments
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 differences between shared_ptr and unique_ptr? 4...
  • May 16, 2022
  • 0 Comments
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 returned value to a variable. #include...
  • May 6, 2022
  • 0 Comments