Function ensureSingleCall
A little utility to ensure a function is only called once
void ensureSingleCall(bool TLS = true, string file = __FILE__, int line = __LINE__)();
Can be used in initialization functions to ensure no double initialization, and will produce a readable output on error. Note that while this is typically used within a function, it could be used to ensure a branch of a function is only executed once.
Parameters
Name | Description |
---|---|
TLS | Whether the check should be thread-local or global (default: true) |
file | The file this is called from, used for deduplication |
line | The line this is called from, used for deduplication |