From a7cc2a594abb74df1d5e7960e68e425bb74f44f0 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 16 Jun 2014 18:43:11 -0400 Subject: [PATCH] Variant - Updated operator*= to handle trivial values. --- src/Variant.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Variant.cpp b/src/Variant.cpp index 3bd4959a4..d0502af07 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -1434,12 +1434,22 @@ Variant& Variant::operator*= (const Variant& other) case type_real: switch (right._type) { - case type_unknown: throw std::string ("Cannot multiply unknown type"); - case type_boolean: right.cast (type_real); _real *= right._real; break; - case type_integer: right.cast (type_real); _real *= right._real; break; - case type_real: _real *= right._real; break; - case type_string: throw std::string ("Cannot multiply real numbers by strings"); - case type_date: throw std::string ("Cannot multiply real numbers by dates"); + case type_unknown: + throw std::string ("Cannot multiply unknown type"); + + case type_boolean: + case type_integer: + case type_real: + right.cast (type_real); + _real *= right._real; + break; + + case type_string: + throw std::string ("Cannot multiply real numbers by strings"); + + case type_date: + throw std::string ("Cannot multiply real numbers by dates"); + case type_duration: _type = type_duration; _duration = (time_t) (unsigned) (int) (_real * static_cast(right._duration));