From 64dd90cfb914805f3334aa32022581e7a05971b7 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:05:56 +0100 Subject: [PATCH] DPL: use requires rather than enable_if / static_assert --- Framework/Core/include/Framework/ServiceRegistry.h | 9 ++++----- Framework/Core/include/Framework/ServiceRegistryRef.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Framework/Core/include/Framework/ServiceRegistry.h b/Framework/Core/include/Framework/ServiceRegistry.h index e3fa23294ee78..2236562e6da75 100644 --- a/Framework/Core/include/Framework/ServiceRegistry.h +++ b/Framework/Core/include/Framework/ServiceRegistry.h @@ -267,33 +267,32 @@ struct ServiceRegistry { /// @deprecated old API to be substituted with the ServiceHandle one template + requires std::is_base_of_v void registerService(C* service, Salt salt = ServiceRegistry::globalDeviceSalt()) { // This only works for concrete implementations of the type T. // We need type elision as we do not want to know all the services in // advance - static_assert(std::is_base_of::value == true, - "Registered service is not derived from declared interface"); constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId()}; ServiceRegistry::registerService(typeHash, reinterpret_cast(service), K, salt, typeid(C).name()); } /// @deprecated old API to be substituted with the ServiceHandle one template + requires std::is_base_of_v void registerService(C const* service, Salt salt = ServiceRegistry::globalDeviceSalt()) { // This only works for concrete implementations of the type T. // We need type elision as we do not want to know all the services in // advance - static_assert(std::is_base_of::value == true, - "Registered service is not derived from declared interface"); constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId()}; this->registerService(typeHash, reinterpret_cast(const_cast(service)), K, salt, typeid(C).name()); } /// Check if service of type T is currently active. template - std::enable_if_t == false, bool> active(Salt salt) const + requires(std::is_const_v == false) + bool active(Salt salt) const { constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId()}; if (this->getPos(typeHash, GLOBAL_CONTEXT_SALT) != -1) { diff --git a/Framework/Core/include/Framework/ServiceRegistryRef.h b/Framework/Core/include/Framework/ServiceRegistryRef.h index fa791cc8c4643..910d4e726c080 100644 --- a/Framework/Core/include/Framework/ServiceRegistryRef.h +++ b/Framework/Core/include/Framework/ServiceRegistryRef.h @@ -72,7 +72,8 @@ class ServiceRegistryRef /// Check if service of type T is currently active. template - std::enable_if_t == false, bool> active() const + requires(std::is_const_v == false) + [[nodiscard]] bool active() const { return mRegistry.active(mSalt); }