Skip to content
Snippets Groups Projects
Commit bf9512e6 authored by Max Kahnt's avatar Max Kahnt
Browse files

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.
parent 8d49bfa8
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
/** \brief Constructor /** \brief Constructor
* *
*/ */
SumFunction(std::vector<BaseType*>& functions, std::vector<double>& coefficients): SumFunction(std::vector<const BaseType*>& functions, std::vector<double>& coefficients):
functions_(functions), functions_(functions),
coefficients_(coefficients) coefficients_(coefficients)
{ {
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
* \param coefficient for summand function * \param coefficient for summand function
* \param function summand function to register * \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); functions_.push_back(&function);
coefficients_.push_back(coefficient); coefficients_.push_back(coefficient);
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
~SumFunction(){} ~SumFunction(){}
private: private:
std::vector<BaseType*> functions_; std::vector<const BaseType*> functions_;
std::vector<double> coefficients_; std::vector<double> coefficients_;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment