fixes #0002460: Use keyword 'explicit' for Quantity constructor

This commit is contained in:
wmayer
2016-11-05 23:21:42 +01:00
parent 96e1b3b16f
commit 9fe82bfbb9
13 changed files with 157 additions and 122 deletions

View File

@@ -92,16 +92,42 @@ bool Quantity::operator >(const Quantity& that) const
return (this->_Value > that._Value) ;
}
bool Quantity::operator <=(const Quantity& that) const
{
if (this->_Unit != that._Unit)
throw Base::Exception("Quantity::operator <=(): quantities need to have same unit to compare");
return (this->_Value <= that._Value) ;
}
bool Quantity::operator >=(const Quantity& that) const
{
if (this->_Unit != that._Unit)
throw Base::Exception("Quantity::operator >=(): quantities need to have same unit to compare");
return (this->_Value >= that._Value) ;
}
Quantity Quantity::operator *(const Quantity &p) const
{
return Quantity(this->_Value * p._Value,this->_Unit * p._Unit);
}
Quantity Quantity::operator *(double p) const
{
return Quantity(this->_Value * p,this->_Unit);
}
Quantity Quantity::operator /(const Quantity &p) const
{
return Quantity(this->_Value / p._Value,this->_Unit / p._Unit);
}
Quantity Quantity::operator /(double p) const
{
return Quantity(this->_Value / p,this->_Unit);
}
Quantity Quantity::pow(const Quantity &p) const
{
if (!p._Unit.isEmpty())
@@ -112,6 +138,13 @@ Quantity Quantity::pow(const Quantity &p) const
);
}
Quantity Quantity::pow(double p) const
{
return Quantity(
std::pow(this->_Value, p), this->_Unit
);
}
Quantity Quantity::operator +(const Quantity &p) const
{
if (this->_Unit != p._Unit)
@@ -329,7 +362,6 @@ int QuantityLexer(void);
Quantity Quantity::parse(const QString &string)
{
// parse from buffer
QuantityParser::YY_BUFFER_STATE my_string_buffer = QuantityParser::yy_scan_string (string.toUtf8().data());
// set the global return variables