diff options
-rw-r--r-- | include/mbgl/map/mode.hpp | 15 | ||||
-rw-r--r-- | include/mbgl/map/update.hpp | 9 | ||||
-rw-r--r-- | include/mbgl/util/geo.hpp | 14 | ||||
-rw-r--r-- | include/mbgl/util/traits.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/render_pass.hpp | 10 |
5 files changed, 26 insertions, 26 deletions
diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp index 074bc3f08e..80ba4d7563 100644 --- a/include/mbgl/map/mode.hpp +++ b/include/mbgl/map/mode.hpp @@ -1,5 +1,7 @@ #pragma once +#include <mbgl/util/traits.hpp> + #include <cstdint> namespace mbgl { @@ -48,17 +50,16 @@ enum class MapDebugOptions : EnumType { #endif // GL_ES_VERSION_2_0 }; -inline MapDebugOptions operator| (const MapDebugOptions& lhs, const MapDebugOptions& rhs) { - return MapDebugOptions(static_cast<EnumType>(lhs) | static_cast<EnumType>(rhs)); +constexpr MapDebugOptions operator|(MapDebugOptions lhs, MapDebugOptions rhs) { + return MapDebugOptions(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs)); } -inline MapDebugOptions& operator|=(MapDebugOptions& lhs, const MapDebugOptions& rhs) { - lhs = lhs | rhs; - return lhs; +constexpr MapDebugOptions& operator|=(MapDebugOptions& lhs, MapDebugOptions rhs) { + return (lhs = lhs | rhs); } -inline bool operator& (const MapDebugOptions& lhs, const MapDebugOptions& rhs) { - return static_cast<EnumType>(lhs) & static_cast<EnumType>(rhs); +constexpr bool operator&(MapDebugOptions lhs, MapDebugOptions rhs) { + return mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs); } } // namespace mbgl diff --git a/include/mbgl/map/update.hpp b/include/mbgl/map/update.hpp index 1c1270ac70..36ce59c01d 100644 --- a/include/mbgl/map/update.hpp +++ b/include/mbgl/map/update.hpp @@ -17,16 +17,15 @@ enum class Update : uint8_t { AnnotationData = 1 << 7, }; -inline Update operator| (const Update& lhs, const Update& rhs) { +constexpr Update operator|(Update lhs, Update rhs) { return Update(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs)); } -inline Update& operator|=(Update& lhs, const Update& rhs) { - lhs = lhs | rhs; - return lhs; +constexpr Update& operator|=(Update& lhs, const Update& rhs) { + return (lhs = lhs | rhs); } -inline bool operator& (const Update& lhs, const Update& rhs) { +constexpr bool operator& (Update lhs, Update rhs) { return mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs); } diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index 4af8906465..a68058048d 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -57,11 +57,11 @@ public: LatLng(const UnwrappedTileID& id); }; -inline bool operator==(const LatLng& a, const LatLng& b) { +constexpr bool operator==(const LatLng& a, const LatLng& b) { return a.latitude == b.latitude && a.longitude == b.longitude; } -inline bool operator!=(const LatLng& a, const LatLng& b) { +constexpr bool operator!=(const LatLng& a, const LatLng& b) { return !(a == b); } @@ -78,7 +78,7 @@ public: } }; -inline bool operator==(const ProjectedMeters& a, const ProjectedMeters& b) { +constexpr bool operator==(const ProjectedMeters& a, const ProjectedMeters& b) { return a.northing == b.northing && a.easting == b.easting; } @@ -164,15 +164,15 @@ private: LatLngBounds(LatLng sw_, LatLng ne_) : sw(std::move(sw_)), ne(std::move(ne_)) {} - friend bool operator==(const LatLngBounds&, const LatLngBounds&); - friend bool operator!=(const LatLngBounds&, const LatLngBounds&); + friend constexpr bool operator==(const LatLngBounds&, const LatLngBounds&); + friend constexpr bool operator!=(const LatLngBounds&, const LatLngBounds&); }; -inline bool operator==(const LatLngBounds& a, const LatLngBounds& b) { +constexpr bool operator==(const LatLngBounds& a, const LatLngBounds& b) { return a.sw == b.sw && a.ne == b.ne; } -inline bool operator!=(const LatLngBounds& a, const LatLngBounds& b) { +constexpr bool operator!=(const LatLngBounds& a, const LatLngBounds& b) { return !(a == b); } diff --git a/include/mbgl/util/traits.hpp b/include/mbgl/util/traits.hpp index 7c9499897e..9d6f947cd2 100644 --- a/include/mbgl/util/traits.hpp +++ b/include/mbgl/util/traits.hpp @@ -5,8 +5,8 @@ namespace mbgl { template<typename T> -constexpr auto underlying_type(T t) -> typename std::underlying_type<T>::type { - return static_cast<typename std::underlying_type<T>::type>(t); +constexpr auto underlying_type(T t) -> typename std::underlying_type_t<T> { + return typename std::underlying_type_t<T>(t); } } // namespace mbgl diff --git a/src/mbgl/renderer/render_pass.hpp b/src/mbgl/renderer/render_pass.hpp index e31383b7cf..93edac2039 100644 --- a/src/mbgl/renderer/render_pass.hpp +++ b/src/mbgl/renderer/render_pass.hpp @@ -12,16 +12,16 @@ enum class RenderPass : uint8_t { Translucent = 1 << 1, }; -constexpr inline RenderPass operator|(RenderPass a, RenderPass b) { - return static_cast<RenderPass>(mbgl::underlying_type(a) | mbgl::underlying_type(b)); +constexpr RenderPass operator|(RenderPass a, RenderPass b) { + return RenderPass(mbgl::underlying_type(a) | mbgl::underlying_type(b)); } -inline RenderPass operator|=(RenderPass& a, RenderPass b) { +constexpr RenderPass& operator|=(RenderPass& a, RenderPass b) { return (a = a | b); } -constexpr inline RenderPass operator&(RenderPass a, RenderPass b) { - return static_cast<RenderPass>(mbgl::underlying_type(a) & mbgl::underlying_type(b)); +constexpr RenderPass operator&(RenderPass a, RenderPass b) { + return RenderPass(mbgl::underlying_type(a) & mbgl::underlying_type(b)); } } // namespace mbgl |