Skip to content

Commit

Permalink
feat: ProxyAccessor constructor can now be constexpr (acts-project#3757)
Browse files Browse the repository at this point in the history
Since C++20 supports `constexpr std::string`, we can make `ProxyAccessorBase(const std::string& _key)` constructor `constexpr`.
  • Loading branch information
timadye authored and Rosie-Hasan committed Nov 13, 2024
1 parent 3f9d2cd commit 2a13ea5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Core/include/Acts/EventData/ProxyAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ACTS_DOES_NOT_COMPILE_SUITE_BEGIN(BuildFromConstRef)
(void)t;

ConstProxyAccessor<unsigned int> caccNMeasuements("nMeasurements");
static_cast<void>(caccNMeasuements); // suppressed unused warning
ACTS_DOES_NOT_COMPILE_BEGIN(ConstAccessorMutate)
caccNMeasuements(t) = 66;
ACTS_DOES_NOT_COMPILE_END()
Expand Down

0 comments on commit 2a13ea5

Please sign in to comment.