ezconfig
Create C++ Objects from Yaml and Json
Loading...
Searching...
No Matches
global.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Petter Nilsson. MIT License. https://github.com/pettni/ezconfig
2
8#pragma once
9
10namespace ezconfig {
11
17template<typename T>
19
20}; // namespace ezconfig
21
29#define EZ_GLOBAL_DECLARE(...) \
30 template<> \
31 __VA_ARGS__ & ::ezconfig::gInstance<__VA_ARGS__>()
32
40#define EZ_GLOBAL_DEFINE(...) \
41 template<> \
42 __VA_ARGS__ & ::ezconfig::gInstance<__VA_ARGS__>() \
43 { \
44 static __VA_ARGS__ global_instance{}; \
45 return global_instance; \
46 } \
47 static_assert(true)
48
52#define EZ_GLOBAL_INSTANCE(...) ::ezconfig::gInstance<__VA_ARGS__>()
T & gInstance()
Getter for global instances.