diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/style/function.hpp | 12 | ||||
-rw-r--r-- | include/mbgl/style/property_value.hpp | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/mbgl/style/function.hpp b/include/mbgl/style/function.hpp index 44ffa31079..97e880b280 100644 --- a/include/mbgl/style/function.hpp +++ b/include/mbgl/style/function.hpp @@ -21,7 +21,19 @@ public: private: float base = 1; std::vector<std::pair<float, T>> stops; + + template <class S> friend bool operator==(const Function<S>&, const Function<S>&); }; +template <class T> +bool operator==(const Function<T>& lhs, const Function<T>& rhs) { + return lhs.base == rhs.base && lhs.stops == rhs.stops; +} + +template <class T> +bool operator!=(const Function<T>& lhs, const Function<T>& rhs) { + return !(lhs == rhs); +} + } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp index d8f83a0fb3..d7e160fdca 100644 --- a/include/mbgl/style/property_value.hpp +++ b/include/mbgl/style/property_value.hpp @@ -8,12 +8,17 @@ namespace style { class Undefined {}; +inline bool operator==(const Undefined&, const Undefined&) { return true; } +inline bool operator!=(const Undefined&, const Undefined&) { return false; } + template <class T> class PropertyValue { private: using Value = variant<Undefined, T, Function<T>>; Value value; + template <class S> friend bool operator==(const PropertyValue<S>&, const PropertyValue<S>&); + public: PropertyValue() : value() {} PropertyValue( T constant) : value(constant) {} @@ -34,5 +39,15 @@ public: } }; +template <class T> +bool operator==(const PropertyValue<T>& lhs, const PropertyValue<T>& rhs) { + return lhs.value == rhs.value; +} + +template <class T> +bool operator!=(const PropertyValue<T>& lhs, const PropertyValue<T>& rhs) { + return !(lhs == rhs); +} + } // namespace style } // namespace mbgl |