From 5dd7fe79035cae38b73696547986991d7294eacd Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sun, 30 Jun 2024 11:52:15 +0000 Subject: [PATCH] Add constexpr constructor check --- include/cserver/engine/components.hpp | 94 +++++++++++++++++++-------- tests/all_meta.cpp | 6 +- 2 files changed, 71 insertions(+), 29 deletions(-) diff --git a/include/cserver/engine/components.hpp b/include/cserver/engine/components.hpp index 445625e..a4fcdd4 100644 --- a/include/cserver/engine/components.hpp +++ b/include/cserver/engine/components.hpp @@ -12,11 +12,11 @@ struct SeparatedComponent {}; template struct Options : utempl::TypeList {}; -template +template struct ComponentConfig { using Type = T; static constexpr auto kOptions = Options; - static constexpr auto kName = name; + static constexpr auto kName = Name; }; namespace impl { @@ -121,10 +121,43 @@ struct AsyncConditionVariable { bool flag; }; +template +struct ServiceContextForComponent { + T& context; + static constexpr auto kConfig = T::kConfig; + static constexpr auto kUtils = T::kUtils; + + template + constexpr auto FindComponent() -> decltype(this->context.template FindComponent()) { + return this->context.template FindComponent(); + }; + + template + constexpr auto FindComponent() -> decltype(FindComponent()) { + return this->FindComponent(); + }; + template