From 28aa4e7ca5285187ceeb0a47867283d7b24e3d8c Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Thu, 29 Aug 2024 10:39:01 +0200 Subject: [PATCH] Added macro helper for Registrar --- include/aidge/utils/Registrar.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/aidge/utils/Registrar.hpp b/include/aidge/utils/Registrar.hpp index 1d76d859e..6323b2abd 100644 --- a/include/aidge/utils/Registrar.hpp +++ b/include/aidge/utils/Registrar.hpp @@ -141,4 +141,13 @@ void declare_registrable(py::module& m, const std::string& class_name){ } +#define CONCAT(a, b) CONCAT_INNER(a, b) +#define CONCAT_INNER(a, b) a ## b + +#define REGISTRAR(cls, ...) \ + namespace { \ + static Registrar<cls> CONCAT(CONCAT(aidge_register_ , cls), __COUNTER__)(__VA_ARGS__); \ + } \ + static_assert(true, "") + #endif //AIDGE_CORE_UTILS_REGISTRAR_H_ -- GitLab