SUNphi  1.0
StaticMemberWithInitializator.hpp
Go to the documentation of this file.
1 #ifndef _STATIC_MEMBER_WITH_INITIALIZATOR_HPP
2 #define _STATIC_MEMBER_WITH_INITIALIZATOR_HPP
3 
4 /// \file StaticMemberWithInitializator.hpp
5 ///
6 /// \brief Provides a static member with an initalizator
7 
8 #include <metaprogramming/SwallowSemicolon.hpp>
9 
10 /// Provides a static member with an initalizator
11 ///
12 /// A method NAME() is provided, which gives access to the internal
13 /// data. This is implemented to avoid out-of-line initialization,
14 /// following the advice of https://stackoverflow.com/a/31608148
15 #define PROVIDE_STATIC_MEMBER_WITH_INITIALIZATOR(T,NAME,VALUE,DESCRIPTION)
16  /*! DESCRIPTION */
17  static int& NAME()
18  {
19  /*! Internal storage */
20  static int _ ## NAME
21  =VALUE;
22 
23  return _ ## NAME;
24  }
25 
26 
27 #endif