Liste des Groupes | Revenir à cl c++ |
On Sun, 30 Mar 2025 20:17:23 +0200, Bonita Montero wrote:Yes, my typical implementation is a global pointer (or static member of a class, not significantly different in function), which code can do a check for zero, if it sees it zero calls the generator function which sets the variable to the address of the local static variable.
Am 30.03.2025 um 20:11 schrieb Mr Flibble:But that is nevertheless what the Meyers Singleton involves. Static local
>No what I meant was the Meyers Singleton which involves static local>
variables NOT static member variables which is what YOU thought it
meant.
static local variables need double-checked locked initialization.
That's rather slow to just get a reference.
initialisation has been threadsafe since C++11 and if performance is a
concern then you can always cache the result in a reference downstream in
any hot path that needs it.
/Flibble
Les messages affichés proviennent d'usenet.