Conditionally Explicit Constructor

Learn how to write a generic constructor with explicit expressions.

We'll cover the following

The improvements to templates make C++20 more consistent and, therefore, less error-prone when you are writing generic programs.

Introduction

Sometimes you need a class that should have constructors accepting different types. For example, you have a class VariantWrapper that holds a std::variant accepting various types as follows:

Get hands-on with 1400+ tech skills courses.