Variadic Template C++: Implementing Unsophisticated Tuple

From C++11, std::tuple is an incredible expansion to Modern C++ that offers a fixed-size col­lec­tion of het­ero­ge­neous values. Un­for­tu­nately, tu­ples can be somewhat dubious to manage in a conventional fash­ion. But, subsequently released C++ stan­dard in­tro­duced a few fea­tures and helpers that greatly re­duce the nec­es­sary boil­er­plate. 

So, in this article, I will explain the variadic template in C++ with the help of unsophisticated tuple implementation. I'll also walk you through a tricky part of tuple i.e. loop through tuple element. Because I have covered the variadic template in my prior article i.e. C++ Template: A Quick UpToDate Look, my focus here would be a blend of variadic template and tuple implementation with more up to date C++ gauges.

Dependency Inversion Principle in C++: SOLID as a Rock

Dependency Inversion Principle(in C++) is the fifth and last design principle of a series SOLID as a Rock design principles. The SOLID design principles focus on developing software that is easy to maintainable, reusable, and extendable. In this article, we will see an example code with the flow and correct it with help of DIP. We will also see guidelines and benefits of DIP at the ens of the article.

By the way, If you haven't gone through my previous articles on design principles, then check out the following quick links:

Interface Segregation Principle | SOLID as a Rock

Interface Segregation Principle in C++ is the fourth & by far the simplest design principle of a series SOLID as a Rock design principles. The SOLID design principles focus on developing software that is easy to maintainable, reusable & extendable. In this article, we will see a code violating ISP, a solution to the same code, guideline & benefits of ISP.

By the way, If you haven't gone through my previous articles on design principles, then below is the quick links:

Double Dispatch in C++

Double Dispatch in C++ is a mechanism that dispatches a function call to different concrete functions depending on the runtime types of two objects involved in the call. In more simple words, its function calling using two different virtual tables of respective two objects. I know this sounds cryptic, but don't worry I will come to double dispatch solution after trying most of the naive solution so that you will come away with the full understanding of concept without having needless confusions.

Motivation

  • At first, a pointer to a base class made sense; you didn't need to know the actual derived class. So you decided to expose a single collection of base class pointers to your clients like so:
C++




x



1
struct Animal {    
2
    virtual const char *name() = 0;
3
};
4

           
5
using AnimalList = vector<Animal*>;



All About Lambda Functions in C++ (From C++11 to C++17)

Lambda functions are quite an intuitive concept of Modern C++ introduced in C++11, so there are already tons of articles on lambda function tutorials over the internet. But still, there are some untold things (like IIFE, types of lambda, etc.) left, which nobody talks about. Therefore, here I am to not only show you lambda function in C++, but we'll also cover how it works internally and other aspects of Lambda.

The title of this article is a bit misleading. Because lambda doesn't always synthesize to function pointer. It's an expression (precisely unique closure). But I have kept it that way for simplicity. So from now on, I will use lambda function and expression interchangeably.

What Exactly Nullptr Is in C++?

The answer to "What exactly nullptr is in C++?" would be a piece of cake for experienced C++ programmers and for those who are aware of Modern C++ (i.e. keyword). But nullptr is more than just a keyword in C++, and to explain that, I have written this article. But, before I jump into it, we will see issues with NULL. Then, we'll dive into the unsophisticated implementation of  nullptr and some use-cases of nullptr.

Note: This article is more or less the same thing which you can find here, here, and in nullptr proposal(N2431) but with a more organized and simplified explanation.