Search⌘ K
AI Features

The constinit Keyword

Explore how to use the constinit keyword in C++20 to guarantee compile-time initialization of variables with static or thread storage duration. Understand its role in improving program initialization without enforcing constness.

We'll cover the following...

Introduction

constinit can be applied to variables with static storage duration or thread storage duration:

  • Global (namespace) variables, static variables, or static class members have static storage
...