From b1c8927679b1cd76860eb6235bf5bc6393406492 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sun, 30 Jun 2024 12:00:31 +0000 Subject: [PATCH] Add SFINAE friendly for FindComponent --- include/cserver/engine/components.hpp | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/include/cserver/engine/components.hpp b/include/cserver/engine/components.hpp index a4fcdd4..9c277eb 100644 --- a/include/cserver/engine/components.hpp +++ b/include/cserver/engine/components.hpp @@ -133,9 +133,15 @@ struct ServiceContextForComponent { }; template - constexpr auto FindComponent() -> decltype(FindComponent()) { - return this->FindComponent(); + constexpr auto FindComponent() -> auto& + requires (Name == kBasicTaskProcessorName || requires {this->FindComponent();}) { + if constexpr(Name == kBasicTaskProcessorName) { + return this->context.taskProcessor; + } else { + return this->FindComponent(); + }; }; + template