[core] Fix issues with the std:: namespace and old compilers

Specifically when building Android with GCC 4.9 (which Qt still does :-/)
This commit is contained in:
Thiago Marcos P. Santos
2017-07-24 15:36:02 +03:00
parent cb5f498dfe
commit acd95c325a
8 changed files with 39 additions and 3 deletions

View File

@@ -1,9 +1,34 @@
#pragma once
#include <sstream>
#include <string>
#include <cassert>
#include <cstdlib>
#include <exception>
// Polyfill needed by Qt when building for Android with GCC
#if defined(__ANDROID__) && defined(__GLIBCXX__)
namespace std {
template <typename T>
std::string to_string(T value)
{
std::ostringstream oss;
oss << value;
return oss.str();
}
inline int stoi(const std::string &str)
{
return atoi(str.c_str());
}
} // namespace std
#endif
namespace mbgl {
namespace util {

View File

@@ -1,5 +1,6 @@
#pragma once
#include <mbgl/util/string.hpp>
#include <mapbox/geojsonvt.hpp>
#include <mbgl/annotation/annotation.hpp>

View File

@@ -8,6 +8,7 @@
#include <mbgl/style/conversion/light.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/string.hpp>
#include <mapbox/geojsonvt.hpp>

View File

@@ -1,10 +1,13 @@
#include <mbgl/style/sources/geojson_source_impl.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/string.hpp>
#include <mapbox/geojsonvt.hpp>
#include <supercluster.hpp>
#include <cmath>
namespace mbgl {
namespace style {
@@ -52,14 +55,14 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON)
mapbox::supercluster::Options clusterOptions;
clusterOptions.maxZoom = options.clusterMaxZoom;
clusterOptions.extent = util::EXTENT;
clusterOptions.radius = std::round(scale * options.clusterRadius);
clusterOptions.radius = ::round(scale * options.clusterRadius);
data = std::make_unique<SuperclusterData>(
geoJSON.get<mapbox::geometry::feature_collection<double>>(), clusterOptions);
} else {
mapbox::geojsonvt::Options vtOptions;
vtOptions.maxZoom = options.maxzoom;
vtOptions.extent = util::EXTENT;
vtOptions.buffer = std::round(scale * options.buffer);
vtOptions.buffer = ::round(scale * options.buffer);
vtOptions.tolerance = scale * options.tolerance;
data = std::make_unique<GeoJSONVTData>(geoJSON, vtOptions);
}

View File

@@ -7,6 +7,7 @@
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <cmath>
namespace mbgl {
@@ -72,7 +73,7 @@ float determineAverageLineWidth(const std::u16string& logicalInput,
}
}
int32_t targetLineCount = std::fmax(1, std::ceil(totalWidth / maxWidth));
int32_t targetLineCount = ::fmax(1, std::ceil(totalWidth / maxWidth));
return totalWidth / targetLineCount;
}

View File

@@ -2,6 +2,7 @@
#include <mbgl/tile/geometry_tile_data.hpp>
#include <mbgl/renderer/query.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
#include <mbgl/util/string.hpp>
#include <mapbox/geojsonvt.hpp>
#include <supercluster.hpp>

View File

@@ -6,6 +6,8 @@
#include <rapidjson/internal/dtoa.h>
#endif
#include <mbgl/util/string.hpp>
namespace mbgl {
namespace util {

View File

@@ -1,5 +1,7 @@
#include <mbgl/util/http_header.hpp>
#include <mbgl/util/string.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wunused-parameter"