Have you ever wondered how programming languages bridge the gap between your ideas and real-world applications? C++ has been a cornerstone in the software development world since its creation. Designed by Bjarne Stroustrup in the 1980s, this versatile, high-performance language has shaped modern programming paradigms with its powerful support for Object-Oriented Programming (OOP). Whether you’re … Continue reading “C++ Object Oriented Programming”
Brian Kernighan’s Algorithm to Count the Set Bits of a Number
To count all set bits of a number, we can loop through all the bits and check whether any bit is set. For example, an integer has 32 bits. We can check all 32 bits in a loop to count the set (1) bits. Here will see how we can improve this mechanism using Brian … Continue reading “Brian Kernighan’s Algorithm to Count the Set Bits of a Number”
Implement Bubble Sort in C
Bubble Sort is one of the most fundamental sorting algorithms, often introduced early in programming courses due to its simplicity. Although not efficient for large datasets, it serves as a great starting point for understanding sorting mechanisms. In this post, we’ll learn how Bubble Sort works, explore its variations, and implement it in C with … Continue reading “Implement Bubble Sort in C”
Introduction to AI/ML: A Journey Through Innovation
Artificial Intelligence (AI) and Machine Learning (ML) are not just buzzwords—they represent a profound shift in how humanity approaches problem-solving and innovation. From enabling smarter technologies to addressing some of the world’s most pressing challenges, AI and ML have become cornerstones of the modern era. This introduction sets the stage for understanding their impact, evolution, … Continue reading “Introduction to AI/ML: A Journey Through Innovation”
std::weak_ptr in C++
The std::weak_ptr is part of the smart pointer family introduced in C++11 which holds a non-owning reference to an object managed by other std::shared_ptrs. It does not own the object, which means that the existence of a std::weak_ptr does not ensure the validity of the referred object. If all the std::shared_ptrs, owing the object, get … Continue reading “std::weak_ptr in C++”
std::async – Execute a Function Asynchronously
The function template, std::async, allows us to run a function (possibly time consuming) asynchronously. The actual function, that needs to be executed asynchronously, is passed to this std::sync. The std::sync returns a future object immediately without waiting for the passed function to finish execution. When the function execution will start depends of the options passed … Continue reading “std::async – Execute a Function Asynchronously”
C++ Promise and Future
C++11 introduced the concept of promise and future to a provide synchronization point between threads by sharing objects. The promise object owner (the producer thread) promises to produce a value – may not be immediately but sometime in future. The future owner (the consumer thread) expects a value once the associated promise is met by … Continue reading “C++ Promise and Future”
std::move vs std::forward
The std::move and std::forward are used to serve two different purposes. The std::move enables move semantic for efficient resource transfer from one object to another. Whereas, the std::forward is used to preserve the value category (lvalue or rvalue) of the parent function’s template parameter in time of calling another function. This feature is also known … Continue reading “std::move vs std::forward”