Considering Threadability

    Besides being global data, statics are not always constructed and deconstructed as you would expect. This is particularly true in cross-platform environments. See for example, regarding the order of destruction of shared static data loaded from dynamic modules.

    A singleton is often implemented with a static and/or .

    For member variables it is good practice to use mutex and mutable together. This applies in both ways:

    • A mutable member variable is presumed to be a shared variable so it should be synchronized with a mutex (or made atomic)
    • If a member variable is itself a mutex, it should be mutable. This is required to use it inside a const member function.

    See also related safety discussion about return values