From bf9512e67747ef20cb6c3e5a0fa35e68c7ec67d8 Mon Sep 17 00:00:00 2001 From: Max Kahnt <max.kahnt@fu-berlin.de> Date: Thu, 7 Aug 2014 15:11:10 +0200 Subject: [PATCH] Let SumFunction use pointer to const functions. The BaseType functions are VirtualFunctions exhibiting const methods only anyway, so it should accept const BaseType functions directly. Otherwise explicit and unneccessary const_cast is needed when SumFunctions are used. --- dune/fufem/functions/sumfunction.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dune/fufem/functions/sumfunction.hh b/dune/fufem/functions/sumfunction.hh index c4024461..983e1e5e 100644 --- a/dune/fufem/functions/sumfunction.hh +++ b/dune/fufem/functions/sumfunction.hh @@ -33,7 +33,7 @@ public: /** \brief Constructor * */ - SumFunction(std::vector<BaseType*>& functions, std::vector<double>& coefficients): + SumFunction(std::vector<const BaseType*>& functions, std::vector<double>& coefficients): functions_(functions), coefficients_(coefficients) { @@ -70,7 +70,7 @@ public: * \param coefficient for summand function * \param function summand function to register */ - virtual void registerFunction(double coefficient, BaseType& function) + virtual void registerFunction(double coefficient, const BaseType& function) { functions_.push_back(&function); coefficients_.push_back(coefficient); @@ -79,7 +79,7 @@ public: ~SumFunction(){} private: - std::vector<BaseType*> functions_; + std::vector<const BaseType*> functions_; std::vector<double> coefficients_; }; -- GitLab