From 1a32cc56304ab0e85c937177a0180f92851d818e Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 12 May 2014 10:12:09 +0100 Subject: [PATCH 1/2] + add eq/neq operators value_null <--> T --- include/mapnik/value_types.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/mapnik/value_types.hpp b/include/mapnik/value_types.hpp index 5f4133947..680790607 100644 --- a/include/mapnik/value_types.hpp +++ b/include/mapnik/value_types.hpp @@ -53,12 +53,26 @@ struct value_null return true; } + template + bool operator==(T const& other) const + { + boost::ignore_unused_variable_warning(other); + return false; + } + bool operator!=(value_null const& other) const { boost::ignore_unused_variable_warning(other); return false; } + template + bool operator!=(T const& other) const + { + boost::ignore_unused_variable_warning(other); + return true; + } + template value_null operator+ (T const& other) const { From ba35dfe3b040f8e7b62d8e99913e54a6c3b8d581 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 12 May 2014 10:14:10 +0100 Subject: [PATCH 2/2] mapnik::value - return 'infinity' if rhs == 0 to avoid division by zero --- include/mapnik/value.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 6229c7b79..e0e8333ef 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -496,6 +496,7 @@ struct div: public boost::static_visitor template value_type operator() (T lhs, T rhs) const { + if (rhs == 0) return std::numeric_limits::infinity(); return lhs / rhs; } @@ -514,11 +515,13 @@ struct div: public boost::static_visitor value_type operator() (value_double lhs, value_integer rhs) const { + if (rhs == 0) return std::numeric_limits::infinity(); return lhs / rhs; } value_type operator() (value_integer lhs, value_double rhs) const { + if (rhs == 0) return std::numeric_limits::infinity(); return lhs / rhs; } };