C++20 designated initializers

The C++20 standard provides new ways to initialize aggregates. These are:

  • list initialization with designated initializers, that has the following forms:
    T object = { .designator = arg1 , .designator { arg2 } ... };
    T object { .designator = arg1 , .designator { arg2 } ... };
  • direct initialization, that has the following form:
    T object (arg1, arg2, ...);

In this article, we will see how list initialization with designated initializers work.