Gate-keeper that ensures a block of code is executed only once.
Declared in <bsls_bslonce.h>
struct BslOnce;
This struct provides a simple data type for ensuring a block of code is executed (only) once. Note that this is defined as a struct to allow constant initialization in a global or static context using BSLS_BSLONCE_INITIALIZER.
| Name | Description |
|---|---|
enter | Enter the one-time block of code. |
leave | Exit the one-time block of code. The behavior is undefined unless the caller had previously called enter, and enter had returned true. |
| Name | Description |
|---|---|
d_onceState | State of the one-time block of code managed by this object. |