Varun

NumPy Array Attributes

NumPy is a library in Python that provides a high-performance multidimensional array objects, along with that it provides the tools for working with these arrays. An array is a central data structure of the NumPy library, and it is used for representing vectors, matrices, and higher-dimensional datasets. Introduction To begin using NumPy, you first need

NumPy Array Attributes Read More »

How to use unique_ptr with Arrays in C++?

In Modern C++, we can create unique_ptr object to manage dynamically allocated arrays. However, the syntax for using std::unique_ptr with arrays is a bit different. In this article, we will look into this in more detail. Syntax to use unique_ptr with Arrays When you want a create a unique_ptr object to manage a dynamically allocated

How to use unique_ptr with Arrays in C++? Read More »

How to pass unique_ptr into a Function in C++?

Unique pointers (std::unique_ptr) is a Smart Pointer and was introduced in C++11. It provide exclusive ownership of a dynamically allocated memory. Unlike regular pointers or std::shared_ptr, std::unique_ptr ensures there is only one owner for the allocated memory, making it a safe and efficient way to handle dynamic memory in C++. In this article, we will

How to pass unique_ptr into a Function in C++? Read More »

How to Return unique_ptr from a function in C++?

Returning a unique_ptr from a function is a common and recommended practice when you want to transfer ownership of dynamically allocated objects without the risk of memory leaks. Here is how you can return a unique_ptr from a function in C++. Returning a unique_ptr Directly C++ supports Return Value Optimization (RVO) and move semantics, which

How to Return unique_ptr from a function in C++? Read More »

Reset unique_ptr in Modern C++

When working with unique_ptr in C++, it’s essential to know how to renounce the ownership of the managed object and free the associated memory when necessary. The unique_ptr class provides the reset() member function for this purpose. The unique_ptr::reset() Function Calling the reset() method on a unique_ptr will perform two operations: Example of reset() function

Reset unique_ptr in Modern C++ Read More »

Scroll to Top