From 6282b28b6fe218390b843a8a71bb5cc2b63dd05c Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 11 Jul 2017 15:32:51 +0300 Subject: [core] Added MBGL_CONSTEXPR to satisfy GCC 4.9 --- include/mbgl/map/mode.hpp | 11 ++++++----- include/mbgl/util/convert.hpp | 4 +++- include/mbgl/util/util.hpp | 7 +++++++ 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp index afec5c0a08..05de2df22c 100644 --- a/include/mbgl/map/mode.hpp +++ b/include/mbgl/map/mode.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -51,23 +52,23 @@ enum class MapDebugOptions : EnumType { #endif // MBGL_USE_GLES2 }; -constexpr MapDebugOptions operator|(MapDebugOptions lhs, MapDebugOptions rhs) { +MBGL_CONSTEXPR MapDebugOptions operator|(MapDebugOptions lhs, MapDebugOptions rhs) { return MapDebugOptions(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs)); } -constexpr MapDebugOptions& operator|=(MapDebugOptions& lhs, MapDebugOptions rhs) { +MBGL_CONSTEXPR MapDebugOptions& operator|=(MapDebugOptions& lhs, MapDebugOptions rhs) { return (lhs = MapDebugOptions(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs))); } -constexpr bool operator&(MapDebugOptions lhs, MapDebugOptions rhs) { +MBGL_CONSTEXPR bool operator&(MapDebugOptions lhs, MapDebugOptions rhs) { return mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs); } -constexpr MapDebugOptions& operator&=(MapDebugOptions& lhs, MapDebugOptions rhs) { +MBGL_CONSTEXPR MapDebugOptions& operator&=(MapDebugOptions& lhs, MapDebugOptions rhs) { return (lhs = MapDebugOptions(mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs))); } -constexpr MapDebugOptions operator~(MapDebugOptions value) { +MBGL_CONSTEXPR MapDebugOptions operator~(MapDebugOptions value) { return MapDebugOptions(~mbgl::underlying_type(value)); } diff --git a/include/mbgl/util/convert.hpp b/include/mbgl/util/convert.hpp index c2b3d9950d..bedb1a4a08 100644 --- a/include/mbgl/util/convert.hpp +++ b/include/mbgl/util/convert.hpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -7,7 +9,7 @@ namespace util { template::value>> -constexpr std::array convert(const std::array&from) { +MBGL_CONSTEXPR std::array convert(const std::array&from) { std::array to {}; std::copy(std::begin(from), std::end(from), std::begin(to)); return to; diff --git a/include/mbgl/util/util.hpp b/include/mbgl/util/util.hpp index c5a7cb3780..7960b40299 100644 --- a/include/mbgl/util/util.hpp +++ b/include/mbgl/util/util.hpp @@ -12,3 +12,10 @@ #define MBGL_VERIFY_THREAD(tid) #endif + +// GCC 4.9 compatibility +#if !defined(__GNUC__) || __GNUC__ >= 5 +#define MBGL_CONSTEXPR constexpr +#else +#define MBGL_CONSTEXPR inline +#endif -- cgit v1.2.1