diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 0909f2b65..dca9694b3 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -477,12 +477,46 @@ template struct sub { using value_type = V; - template - value_type operator() (T1 const& lhs, T2 const&) const + + value_type operator() (value_null const& lhs , + value_null const& rhs) const { return lhs; } + value_type operator() (value_null, value_unicode_string const& rhs) const + { + return rhs; + } + value_type operator() (value_unicode_string const& lhs, value_null) const + { + return lhs; + } + + template + value_type operator() (value_unicode_string const& lhs, R const&) const + { + return lhs; + } + + template + value_type operator() (L const&, value_unicode_string const& rhs) const + { + return rhs; + } + + template + value_type operator() (L const& lhs, value_null const&) const + { + return lhs; + } + + template + value_type operator() (value_null const&, R const& rhs) const + { + return rhs; + } + template value_type operator() (T lhs, T rhs) const { @@ -495,15 +529,12 @@ struct sub return value_type(); } - value_type operator() (value_double lhs, value_integer rhs) const + template + value_type operator() (T1 const& lhs, T2 const& rhs) const { - return lhs - rhs; + return typename std::common_type::type{ lhs - rhs }; } - value_type operator() (value_integer lhs, value_double rhs) const - { - return lhs - rhs; - } value_type operator() (value_bool lhs, value_bool rhs) const { @@ -515,11 +546,47 @@ template struct mult { using value_type = V; - template - value_type operator() (T1 const& lhs , T2 const& ) const + + value_type operator() (value_null const& lhs , + value_null const& rhs) const { return lhs; } + + value_type operator() (value_unicode_string const& lhs, value_null) const + { + return lhs; + } + + value_type operator() (value_null, value_unicode_string const& rhs) const + { + return rhs; + } + + template + value_type operator() (L const& lhs, value_null const&) const + { + return lhs; + } + + template + value_type operator() (value_null const&, R const& rhs) const + { + return rhs; + } + + template + value_type operator() (value_unicode_string const& lhs, R const&) const + { + return lhs; + } + + template + value_type operator() (L const&, value_unicode_string const& rhs) const + { + return rhs; + } + template value_type operator() (T lhs, T rhs) const { @@ -532,19 +599,15 @@ struct mult return value_type(); } - value_type operator() (value_double lhs, value_integer rhs) const + template + value_type operator() (T1 const& lhs, T2 const& rhs) const { - return lhs * rhs; + return typename std::common_type::type{ lhs * rhs }; } - value_type operator() (value_integer lhs, value_double rhs) const + value_type operator() (value_bool lhs, value_bool rhs) const { - return lhs * rhs; - } - - value_type operator() (value_bool, value_bool) const - { - return value_integer(0); + return value_integer(lhs * rhs); } }; @@ -552,12 +615,35 @@ template struct div { using value_type = V; - template - value_type operator() (T1 const& lhs, T2 const&) const + + value_type operator() (value_null const& lhs , + value_null const& rhs) const { return lhs; } + value_type operator() (value_unicode_string const& lhs, value_null) const + { + return lhs; + } + + value_type operator() (value_null, value_unicode_string const& rhs) const + { + return rhs; + } + + template + value_type operator() (L const& lhs, value_null const&) const + { + return lhs; + } + + template + value_type operator() (value_null const&, R const& rhs) const + { + return rhs; + } + template value_type operator() (T lhs, T rhs) const { @@ -576,16 +662,23 @@ struct div return value_type(); } - value_type operator() (value_double lhs, value_integer rhs) const + template + value_type operator() (value_unicode_string const& lhs, R const&) const { - if (rhs == 0) return value_type(); - return lhs / rhs; + return lhs; } - value_type operator() (value_integer lhs, value_double rhs) const + template + value_type operator() (L const&, value_unicode_string const& rhs) const + { + return rhs; + } + + template + value_type operator() (T1 const& lhs, T2 const& rhs) const { if (rhs == 0) return value_type(); - return lhs / rhs; + return typename std::common_type::type{ lhs / rhs }; } }; @@ -593,10 +686,11 @@ template struct mod { using value_type = V; + template value_type operator() (T1 const& lhs, T2 const&) const { - return lhs; + return lhs; } template