From 41497e9c4174d310f3a62548f3cfeb9da2852849 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 17 Jun 2016 12:18:39 +0300 Subject: [core] Cleaned up enum classes - Replaced static_cast with C++ casts. - Replaced inline with constexpr. --- include/mbgl/map/mode.hpp | 15 ++++++++------- include/mbgl/map/update.hpp | 9 ++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include/mbgl/map') 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 + #include 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(lhs) | static_cast(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(lhs) & static_cast(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); } -- cgit v1.2.1