I have a problem with the assignment operators. Please have a look at my code below:
template<typename PARAM_TYPE, typename DATA_TYPE>
class Parameter : public boost::units::quantity<PARAM_TYPE, DATA_TYPE>
{
public:
Parameter<PARAM_TYPE, DATA_TYPE> & operator = ( const quantity<PARAM_TYPE, DATA_TYPE> & Q )
{
// ...
}
Parameter<PARAM_TYPE, DATA_TYPE> & operator = ( const Parameter<PARAM_TYPE, DATA_TYPE> & P )
{
// ... do something more than in assignment operator taking quantity
}
};
My problem is when working with Parameter class instances. As you may know the boost::units::quantity
manipulates physical units of the variable. Therefore I have to use all the operators coming from boost::units::quantity
. As a result of such operation is quantity again. For example:
Parameter<si::length> P;
quantity<si::length> Q1( 1.0 * si::meter );
quantity<si::length> Q2 ( 1.0 * si::meter );
P = Q1 + Q2;
So far so good, assignment operator taking quantity is used. The problem comes when doing quite similar thing:
Parameter<si::length> P;
Parameter<si::length> P1( 1.0 * si::meter );
Parameter<si::length> P2 ( 1.0 * si::meter );
P = P1 + P2;
As Parameter<>
is derived from quantity<>
it seems an assignment operator taking quantity as argument is used either!
QUESTION: is there a way to force compiler to use assignment operator taking Parameter<>
as argument while using quantity<>:: operator +
in the second case?
Many thanks in advance to anyone willing to help. Cheers Martin