Move Constructor & Assignment Operator With std::shared_ptr

In an earlier article, we have seen how move constructor & move assignment operators helped us in creating our own unique_ptr. Here we will use move constructor & assignment operator to implement unsophisticated shared_ptr. Implementing Our shared_ptr with Move Constructor & Assignment Operator In some cases, we have a requirement where a single resource is represented by multiple pointers. We can not accomplish this by std::unique_ptr. To accomplish this, we can add a new variable to our smart pointer class which keeps track of reference count at the real-time....

September 15, 2019 · 5 min · 913 words · Vishal Chovatiya

Understanding unique_ptr with Example in C++11

The smart pointers are a really good mechanism to manage dynamically allocated resources. In this article, we will see unique_ptr with example in C++11. But we don’t discuss standard smart pointers from a library. Rather, we implement our own smart pointer equivalent to it. This will give us an idea of inside working of smart pointers. Brief Prior to C++11, the standard provided std::auto_ptr. Which had some limitations. But from C++11, standard provided many smart pointers classes....

September 15, 2019 · 8 min · 1571 words · Vishal Chovatiya