From 8c1f1553996609a94ea0147aa7f682c1e188bd7d Mon Sep 17 00:00:00 2001 From: Tim Adye Date: Tue, 5 Nov 2024 16:13:50 +0000 Subject: [PATCH] feat: ProxyAccessor constructor can now be constexpr (#3757) Since C++20 supports `constexpr std::string`, we can make `ProxyAccessorBase(const std::string& _key)` constructor `constexpr`. --- Core/include/Acts/EventData/ProxyAccessor.hpp | 3 ++- .../UnitTests/Core/EventData/TrackContainerComplianceTests.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/include/Acts/EventData/ProxyAccessor.hpp b/Core/include/Acts/EventData/ProxyAccessor.hpp index 7a9ebe3eff0..429c0ef670b 100644 --- a/Core/include/Acts/EventData/ProxyAccessor.hpp +++ b/Core/include/Acts/EventData/ProxyAccessor.hpp @@ -74,7 +74,8 @@ struct ProxyAccessorBase { /// Create the accessor from a string key /// @param _key the key - ProxyAccessorBase(const std::string& _key) : key{hashString(_key)} {} + constexpr ProxyAccessorBase(const std::string& _key) + : key{hashString(_key)} {} /// Access the stored key on the proxy given as an argument. Mutable version /// @tparam proxy_t the type of the proxy diff --git a/Tests/UnitTests/Core/EventData/TrackContainerComplianceTests.cpp b/Tests/UnitTests/Core/EventData/TrackContainerComplianceTests.cpp index 636b30bff54..731f9e01a47 100644 --- a/Tests/UnitTests/Core/EventData/TrackContainerComplianceTests.cpp +++ b/Tests/UnitTests/Core/EventData/TrackContainerComplianceTests.cpp @@ -75,6 +75,7 @@ ACTS_DOES_NOT_COMPILE_SUITE_BEGIN(BuildFromConstRef) (void)t; ConstProxyAccessor caccNMeasuements("nMeasurements"); + static_cast(caccNMeasuements); // suppressed unused warning ACTS_DOES_NOT_COMPILE_BEGIN(ConstAccessorMutate) caccNMeasuements(t) = 66; ACTS_DOES_NOT_COMPILE_END()