timur.audio

A blog about C++, music software, tech community, and life.

Initialisation in C++17 – the matrix

Recently, I gave a talk titled “Initialisation in modern C++”, which was apparently quite well received. (A video recording is available here).

One of the slides in this talk was a matrix tabulating all the possible initialisation syntaxes and what they do for different kinds of types (such as: built-in types, aggregates, etc.)

Ever since then, I keep getting requests for a high-resolution version of that table. So finally I got around to uploading one. Here it is:

You can freely reuse this table – I hope it will be useful. And please let me know if you spot any mistakes πŸ™‚

Keep in mind that the above table is for C++17, but things will change in C++20, in particular for aggregate types: we will get designated initialisers as well as direct initialisation for aggregates.

3 Comments

  1. Isaac Monteiro

    29 May 2019 at 22:35

    Such a nice quick Referenz table!
    I’m Just starting to learn C++ but this seems to be a very important topic.
    Also, under types w/o user provided ctor | value-init/empty-braces, wouldn’t it be
    Value Initalization(i.e. call default ctor for class types, Zero Initialize otherwise)?

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2019 timur.audio

Theme by Anders NorΓ©nUp ↑