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 ...
-
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 ...
-
May 21, 2022
- 0 Comments
I have some code in a header that looks like this: #include <memory> class Thing; class MyClass { std::unique_ptr< Thing > my_thing; }; ...
-
May 18, 2022
- 0 Comments
std::unique_ptr has support for arrays, for instance: std::unique_ptr<int> p(new int...
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 ...
-
May 16, 2022
- 0 Comments
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 ...
-
May 5, 2022
- 0 Comments