summaryrefslogtreecommitdiff
path: root/include/mbgl/util
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/util')
-rw-r--r--include/mbgl/util/vec.hpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/mbgl/util/vec.hpp b/include/mbgl/util/vec.hpp
index 83530a1798..a8bbd14b0f 100644
--- a/include/mbgl/util/vec.hpp
+++ b/include/mbgl/util/vec.hpp
@@ -105,6 +105,18 @@ struct vec3 {
inline bool operator==(const vec3& rhs) const {
return x == rhs.x && y == rhs.y && z == rhs.z;
}
+
+ template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
+ inline operator bool() const {
+ return !std::isnan(x) && !std::isnan(y) && !std::isnan(z);
+ }
+
+ template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
+ inline operator bool() const {
+ return x != std::numeric_limits<T>::min()
+ && y != std::numeric_limits<T>::min()
+ && z != std::numeric_limits<T>::min();
+ }
};
template <typename T = double>
@@ -117,6 +129,19 @@ struct vec4 {
inline bool operator==(const vec4& rhs) const {
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
}
+
+ template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
+ inline operator bool() const {
+ return !std::isnan(x) && !std::isnan(y) && !std::isnan(z) && !std::isnan(w);
+ }
+
+ template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
+ inline operator bool() const {
+ return x != std::numeric_limits<T>::min()
+ && y != std::numeric_limits<T>::min()
+ && z != std::numeric_limits<T>::min()
+ && w != std::numeric_limits<T>::min();
+ }
};