From 15a1c7b71f276b558f028eabae53456f444cebbc Mon Sep 17 00:00:00 2001 From: Sudarsana Babu Nagineni Date: Mon, 9 Jul 2018 11:18:30 +0300 Subject: Fix compilation errors with libc++ on QNX 7 This patch fixes the compilation errors on QNX 7: 1) QNX 7 compiler (i.e qcc based GCC 5.4.0 with libc++ from LLVM) has a limited c++11 feature support and causing the compilation errors with the inheriting constructors. This fixes the issues by providing the required constructors explicitly. 2) Resolves an ambiguous overload error with optional --- include/mbgl/style/expression/compound_expression.hpp | 5 ++++- src/mbgl/style/expression/interpolate.cpp | 12 ++++++------ src/mbgl/style/expression/match.cpp | 6 +++--- src/mbgl/style/expression/step.cpp | 12 ++++++------ src/mbgl/tile/geometry_tile_data.hpp | 16 ++++++++-------- test/api/recycle_map.cpp | 2 +- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/include/mbgl/style/expression/compound_expression.hpp b/include/mbgl/style/expression/compound_expression.hpp index 04562752a6..c618f2f206 100644 --- a/include/mbgl/style/expression/compound_expression.hpp +++ b/include/mbgl/style/expression/compound_expression.hpp @@ -33,7 +33,10 @@ namespace expression { */ struct VarargsType { type::Type type; }; template -struct Varargs : std::vector { using std::vector::vector; }; +struct Varargs : std::vector { + template + Varargs(Args&&... args) : std::vector(std::forward(args)...) {} +}; namespace detail { // Base class for the Signature structs that are used to determine diff --git a/src/mbgl/style/expression/interpolate.cpp b/src/mbgl/style/expression/interpolate.cpp index 852042382c..54fbc6e1d7 100644 --- a/src/mbgl/style/expression/interpolate.cpp +++ b/src/mbgl/style/expression/interpolate.cpp @@ -170,23 +170,23 @@ ParseResult parseInterpolate(const Convertible& value, ParsingContext& ctx) { labelValue->match( [&](uint64_t n) { if (n > std::numeric_limits::max()) { - label = {std::numeric_limits::infinity()}; + label = optional{std::numeric_limits::infinity()}; } else { - label = {static_cast(n)}; + label = optional{static_cast(n)}; } }, [&](int64_t n) { if (n > std::numeric_limits::max()) { - label = {std::numeric_limits::infinity()}; + label = optional{std::numeric_limits::infinity()}; } else { - label = {static_cast(n)}; + label = optional{static_cast(n)}; } }, [&](double n) { if (n > std::numeric_limits::max()) { - label = {std::numeric_limits::infinity()}; + label = optional{std::numeric_limits::infinity()}; } else { - label = {static_cast(n)}; + label = optional{n}; } }, [&](const auto&) {} diff --git a/src/mbgl/style/expression/match.cpp b/src/mbgl/style/expression/match.cpp index 340f1dab4d..4b4984811f 100644 --- a/src/mbgl/style/expression/match.cpp +++ b/src/mbgl/style/expression/match.cpp @@ -138,7 +138,7 @@ optional parseInputValue(const Convertible& input, ParsingContext& pa parentContext.error("Branch labels must be integers no larger than " + util::toString(Value::maxSafeInteger()) + ".", index); } else { type = {type::Number}; - result = {static_cast(n)}; + result = optional{static_cast(n)}; } }, [&] (int64_t n) { @@ -146,7 +146,7 @@ optional parseInputValue(const Convertible& input, ParsingContext& pa parentContext.error("Branch labels must be integers no larger than " + util::toString(Value::maxSafeInteger()) + ".", index); } else { type = {type::Number}; - result = {n}; + result = optional{n}; } }, [&] (double n) { @@ -156,7 +156,7 @@ optional parseInputValue(const Convertible& input, ParsingContext& pa parentContext.error("Numeric branch labels must be integer values.", index); } else { type = {type::Number}; - result = {static_cast(n)}; + result = optional{static_cast(n)}; } }, [&] (const std::string& s) { diff --git a/src/mbgl/style/expression/step.cpp b/src/mbgl/style/expression/step.cpp index ee6055091e..a1ca0a702e 100644 --- a/src/mbgl/style/expression/step.cpp +++ b/src/mbgl/style/expression/step.cpp @@ -127,23 +127,23 @@ ParseResult Step::parse(const mbgl::style::conversion::Convertible& value, Parsi labelValue->match( [&](uint64_t n) { if (n > std::numeric_limits::max()) { - label = {std::numeric_limits::infinity()}; + label = optional{std::numeric_limits::infinity()}; } else { - label = {static_cast(n)}; + label = optional{static_cast(n)}; } }, [&](int64_t n) { if (n > std::numeric_limits::max()) { - label = {std::numeric_limits::infinity()}; + label = optional{std::numeric_limits::infinity()}; } else { - label = {static_cast(n)}; + label = optional{static_cast(n)}; } }, [&](double n) { if (n > std::numeric_limits::max()) { - label = {std::numeric_limits::infinity()}; + label = optional{std::numeric_limits::infinity()}; } else { - label = {static_cast(n)}; + label = optional{n}; } }, [&](const auto&) {} diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp index 449d8cab28..bd64a1d153 100644 --- a/src/mbgl/tile/geometry_tile_data.hpp +++ b/src/mbgl/tile/geometry_tile_data.hpp @@ -22,19 +22,19 @@ class GeometryCoordinates : public std::vector { public: using coordinate_type = int16_t; - GeometryCoordinates() = default; - GeometryCoordinates(const std::vector& v) - : std::vector(v) {} - GeometryCoordinates(std::vector&& v) - : std::vector(std::move(v)) {} - - using std::vector::vector; + template + GeometryCoordinates(Args&&... args) : std::vector(std::forward(args)...) {} + GeometryCoordinates(std::initializer_list args) + : std::vector(std::move(args)) {} }; class GeometryCollection : public std::vector { public: using coordinate_type = int16_t; - using std::vector::vector; + template + GeometryCollection(Args&&... args) : std::vector(std::forward(args)...) {} + GeometryCollection(std::initializer_list args) + : std::vector(std::move(args)) {} }; class GeometryTileFeature { diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp index ca6abac8c1..fc7e5223ec 100644 --- a/test/api/recycle_map.cpp +++ b/test/api/recycle_map.cpp @@ -35,7 +35,7 @@ TEST(API, RecycleMapUpdateImages) { auto loadStyle = [&](auto markerName, auto markerPath) { auto source = std::make_unique("geometry"); - source->setGeoJSON({ Point { 0, 0 } }); + source->setGeoJSON( Geometry{ Point{ 0, 0 } } ); auto layer = std::make_unique("geometry", "geometry"); layer->setIconImage({ markerName }); -- cgit v1.2.1