LibreOffice: rtl::StaticWithInit< T, InitData, Unique, Data > Class Template Reference

LibreOffice LibreOffice 25.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
rtl::StaticWithInit< T, InitData, Unique, Data > Class Template Reference

Helper base class for a late-initialized static variable, implementing the double-checked locking pattern correctly. More...

`#include <instance.hxx>`

## Static Public Member Functions
static T & | get ()
| Gets the static.

## Detailed Description

template<typename T, typename InitData, typename Unique = InitData, typename Data = T>
class rtl::StaticWithInit< T, InitData, Unique, Data >

Helper base class for a late-initialized static variable, implementing the double-checked locking pattern correctly.

Derive:
  Derive from this class (common practice), providing an initializer functor class, e.g.

      struct MyStatic : public rtl::StaticWithInit<MyType, MyStatic> {
          MyType operator () () {
              ...
              return MyType( ... );
          }
      };
      ...
      MyType & rStatic = MyStatic::get();
      ...

Template Parameters

  T | variable's type
  InitData | initializer functor class
  Unique | Implementation trick to make the inner static holder unique, using the outer class (the one that derives from this base class). Default is InitData (common practice).
  Data | Initializer functor's return type. Default is T (common practice).

## Member Function Documentation

## ◆ get()

template<typename T, typename InitData, typename Unique = InitData, typename Data = T>

T & rtl::StaticWithInit< T, InitData, Unique, Data >::get | ( |  | ) |
| inlinestatic

Gets the static.

Mutual exclusion is performed using the osl global mutex.

Returns
  static variable

The documentation for this class was generated from the following file:

- rtl/instance.hxx