From 8e7d9024b3dbed0065badcb061dd4f78d1f950c7 Mon Sep 17 00:00:00 2001 From: Maximilian Reininghaus <maximilian.reininghaus@kit.edu> Date: Thu, 13 Apr 2023 15:03:05 +0200 Subject: [PATCH] pass callable by value --- corsika/detail/media/NuclearComposition.inl | 4 ++-- corsika/media/NuclearComposition.hpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/corsika/detail/media/NuclearComposition.inl b/corsika/detail/media/NuclearComposition.inl index c499a593d..9d1241aab 100644 --- a/corsika/detail/media/NuclearComposition.inl +++ b/corsika/detail/media/NuclearComposition.inl @@ -46,7 +46,7 @@ namespace corsika { } template <typename TFunction> - inline auto NuclearComposition::getWeighted(TFunction const& func) const { + inline auto NuclearComposition::getWeighted(TFunction func) const { using ResultQuantity = decltype(func(std::declval<Code>())); auto const product = [&](auto const compID, auto const fraction) { return func(compID) * fraction; @@ -66,7 +66,7 @@ namespace corsika { } // namespace corsika template <typename TFunction> - inline auto NuclearComposition::getWeightedSum(TFunction const& func) const + inline auto NuclearComposition::getWeightedSum(TFunction func) const -> decltype(func(std::declval<Code>())) { using ResultQuantity = decltype(func(std::declval<Code>())); diff --git a/corsika/media/NuclearComposition.hpp b/corsika/media/NuclearComposition.hpp index 184853ef2..402969edb 100644 --- a/corsika/media/NuclearComposition.hpp +++ b/corsika/media/NuclearComposition.hpp @@ -51,7 +51,7 @@ namespace corsika { * @retval returns the vector with weighted return types of func. */ template <typename TFunction> - auto getWeighted(TFunction const& func) const; + auto getWeighted(TFunction func) const; /** * Sum all all relative composition weighted by func(element) @@ -65,8 +65,7 @@ namespace corsika { * @retval returns the weighted sum with the type defined by the return type of func. */ template <typename TFunction> - auto getWeightedSum(TFunction const& func) const - -> decltype(func(std::declval<Code>())); + auto getWeightedSum(TFunction func) const -> decltype(func(std::declval<Code>())); /** * Number of elements in the composition array -- GitLab