global.h 383 B

12345678910111213
  1. #pragma once
  2. //! Defines a global variable that is initialized on its first access.
  3. /*!
  4. * In contrast to a usual variable with static storage duration, this one
  5. * is not susceptible to initialization order fiasco issues.
  6. */
  7. #define YT_DEFINE_GLOBAL(type, name, ...) \
  8. inline type& name() \
  9. { \
  10. static type result{__VA_ARGS__}; \
  11. return result; \
  12. }