19
Jun
2022
Sudoku Solver GUI
Sudoku is the most known brain puzzle game in the world. Everyone thinks the game came from centuries but it is only about 40 years old game. The inventor, Howard Garns published the first modern sudoku in 1979. Every sudoku puzzle is unique. It constitutes 9 boxes, 9 rows, 9 columns, and 81 cells. A... Read More
21
Dec
2021
Move Semantics in the std::remove and std::remove_if
std::remove and std::remove_if functions are Inside the C++ algorithm library. We shouldn’t forget these functions names contain “move” These functions are valid only for more assignable objects. Remove functions returns the end of the iterator for the new range. These functions only remove the elements by shifting. It means, the remove() functions don’t erase the... Read More
16
Dec
2021
Shallow Copy & Deep Copy
“It is only shallow people who do not judge by appearances. The true mystery of the world is the visible, not the invisible….” ― Oscar Wilde, The Picture of Dorian Gray Most of the times something for which is learned deeply is profitable. But always, something for which is performed shallowly is safe. In this blog, we... Read More
18
Oct
2021
Smart Pointers (6/6): Final: Custom Deleters, Passing Smart Pointers…
In the final part, we will take a look at custom deleters and pass the smart pointers to functions, Custom Deleters: Smart pointers have the default deleter but also a custom deleter can be utilized. It brings about some overhead such as increasing the size. We know the std::unique_ptr size is equal to raw’s pointer... Read More
17
Oct
2021
Smart Pointers (5/6): std::weak_ptr
Before talking about the std::weak_ptr, it would be nice to talk about weak and strong type pointers. As an example of a strong type pointer, std::shared_ptr holds the owner and increases its reference counter. It means every strong type pointer keeps alive its resource individually. This feature causes a big problem sometimes. We will talk... Read More
16
Oct
2021
Smart Pointers (4/6): How to Create Our Own Shared Pointer
We’ll write our basic smart shared pointer class to understand very well the std::shared_pointer class. We base our functions on the std::shared_ptr class to select our member functions: Std::shared_ptr has a control block that contains reference counter, weak counter, allocator, and custom deleter. But we design our own basic Shared pointer. That’s why... Read More
14
Oct
2021
Smart Pointers (3/6): std::shared_ptr
Automatic memory management alias garbage collector provides release of memory which was allocated by the program, but, then, is no longer referenced. C++ has no explicit garbage collector mechanism. Quotation from Bjarne Strousb: “I don’t like garbage. I don’t like littering. My ideal is to eliminate the need for a garbage colletor by not producting... Read More
14
Oct
2021
Smart Pointers (2/6): How to Create Our Own Unique Pointer
We’ll write our smart unique pointer class to understand the std::unique_ptr class very well. We have no other intended purpose. Let’s enjoy that and practice our core C++ skills. We base our functions on the std::unique_ptr class to select our member functions. In this way, the functions below are enough to create a basic custom... Read More
14
Oct
2021
Smart Pointers (1/6): std::unique_ptr
If you don’t want to change your raw pointer habits and want to get coverage of smart pointers; then the standard libraries’ unique pointer is the most convenient choice! Std::unique_ptr exclusively manages the resource during its lifetime. Here are some features of the unique pointers with proofs and codes! 1. Std::unique_ptrs are the same size... Read More
14
Oct
2021
Smart Pointers (0/6)
Before talking about smart pointers, I would like to talk briefly about non-smart pointers also known as raw pointers. If we create a primitive type such as “int” or an object on the heap, the memory responsibilities belong to us. Ignoring the memory control mechanism can cause some problems such as having a dangling pointer,... Read More