diff options
author | Wilhelm Berg <wb@BergWerk-GIS.at> | 2018-08-22 16:56:32 +0200 |
---|---|---|
committer | Wilhelm Berg <wb@BergWerk-GIS.at> | 2018-08-22 16:56:32 +0200 |
commit | 797f622a26b34db5a30e7f1728d87c6700a2ec1e (patch) | |
tree | 75ea93979db2baf3eb2234c6fbb3d1a9c5b70329 /include/mbgl/math | |
parent | 86fc3f525e42d042f239876b93525ff411ad7182 (diff) | |
parent | 520df7f02049cdbbb9e68041e755d6c3a8d5b21f (diff) | |
download | qtlocation-mapboxgl-797f622a26b34db5a30e7f1728d87c6700a2ec1e.tar.gz |
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into bwg-vs2017
Diffstat (limited to 'include/mbgl/math')
-rw-r--r-- | include/mbgl/math/log2.hpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/mbgl/math/log2.hpp b/include/mbgl/math/log2.hpp index 6a1ba23ed9..3136ac22b4 100644 --- a/include/mbgl/math/log2.hpp +++ b/include/mbgl/math/log2.hpp @@ -2,6 +2,11 @@ #include <cmath> #include <cstdint> +#include <type_traits> + +#if defined(__ANDROID__) +#include <android/api-level.h> +#endif namespace mbgl { namespace util { @@ -12,3 +17,14 @@ uint32_t ceil_log2(uint64_t x); } // namespace util } // namespace mbgl + +// log2 is not available on Android before API 18. +#if defined(__ANDROID__) && defined(__GNUC__) && \ + defined(__ANDROID_API__) && __ANDROID_API__ < 18 + +template <typename T> +typename std::enable_if_t<std::is_floating_point<T>::value, T> log2(T x) { + return ::log(x) / M_LN2; +} + +#endif |