What is std::unique_ptr? How to Use std::unique_ptr?

The std::unique_ptr is basically a template smart pointer class. It is smart about cleaning up the allocated memory. Template class means this can work with different data types. We have to provide the actual pointer in time of constructing the object. In the desctuctor, the pointer is freed. Another thing is, the usual pointer operator like … Continue reading “What is std::unique_ptr? How to Use std::unique_ptr?”

How to do Asynchronous Operation using boost::asio?

Boost::asio was initially designed for accomplishing time-consuming networking I/O (Input/Output) operations in asynchronous way. I/O operations over network usually takes some time to complete. If you call a function that does I/O operation over network, the calling thread will block until the I/O operation is complete. This is a problem in many situations. For example, … Continue reading “How to do Asynchronous Operation using boost::asio?”

How to Implement Smart Pointer in C++

What is smart pointer in C++? From the name you can guess that smart pointers can do something smart that the normal pointer can not do. Yes, smart pointers can do memory management much better way (smart way) than the normal pointers. Memory management means handling memory leak, dangling pointer, allocation failure etc. Truly speaking, in C++ … Continue reading “How to Implement Smart Pointer in C++”