Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
static_execute.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN, Dec 2021
5 *
6 * Copyright (c) 2022, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
13#ifndef static_execute_h
14#define static_execute_h
15
16// Execute code on library loading by running code in the constructor of a
17// class that is a static class member of another class.
18#define STATIC_EXECUTE(MY_FUNC) \
19 struct StaticExecutorWrapper { \
20 struct Executor { \
21 template <class Func> \
22 Executor(Func func) \
23 { \
24 func(); \
25 } \
26 }; \
27 static Executor executor; \
28 }; \
29 \
30 StaticExecutorWrapper::Executor StaticExecutorWrapper::executor{MY_FUNC};
31
32#endif