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<T>
This commit is contained in:
Sudarsana Babu Nagineni
2018-07-09 11:18:30 +03:00
parent f05199e2d9
commit 15a1c7b71f
6 changed files with 28 additions and 25 deletions

View File

@@ -33,7 +33,10 @@ namespace expression {
*/
struct VarargsType { type::Type type; };
template <typename T>
struct Varargs : std::vector<T> { using std::vector<T>::vector; };
struct Varargs : std::vector<T> {
template <class... Args>
Varargs(Args&&... args) : std::vector<T>(std::forward<Args>(args)...) {}
};
namespace detail {
// Base class for the Signature<Fn> structs that are used to determine

View File

@@ -170,23 +170,23 @@ ParseResult parseInterpolate(const Convertible& value, ParsingContext& ctx) {
labelValue->match(
[&](uint64_t n) {
if (n > std::numeric_limits<double>::max()) {
label = {std::numeric_limits<double>::infinity()};
label = optional<double>{std::numeric_limits<double>::infinity()};
} else {
label = {static_cast<double>(n)};
label = optional<double>{static_cast<double>(n)};
}
},
[&](int64_t n) {
if (n > std::numeric_limits<double>::max()) {
label = {std::numeric_limits<double>::infinity()};
label = optional<double>{std::numeric_limits<double>::infinity()};
} else {
label = {static_cast<double>(n)};
label = optional<double>{static_cast<double>(n)};
}
},
[&](double n) {
if (n > std::numeric_limits<double>::max()) {
label = {std::numeric_limits<double>::infinity()};
label = optional<double>{std::numeric_limits<double>::infinity()};
} else {
label = {static_cast<double>(n)};
label = optional<double>{n};
}
},
[&](const auto&) {}

View File

@@ -138,7 +138,7 @@ optional<InputType> 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<int64_t>(n)};
result = optional<InputType>{static_cast<int64_t>(n)};
}
},
[&] (int64_t n) {
@@ -146,7 +146,7 @@ optional<InputType> 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<InputType>{n};
}
},
[&] (double n) {
@@ -156,7 +156,7 @@ optional<InputType> parseInputValue(const Convertible& input, ParsingContext& pa
parentContext.error("Numeric branch labels must be integer values.", index);
} else {
type = {type::Number};
result = {static_cast<int64_t>(n)};
result = optional<InputType>{static_cast<int64_t>(n)};
}
},
[&] (const std::string& s) {

View File

@@ -127,23 +127,23 @@ ParseResult Step::parse(const mbgl::style::conversion::Convertible& value, Parsi
labelValue->match(
[&](uint64_t n) {
if (n > std::numeric_limits<double>::max()) {
label = {std::numeric_limits<double>::infinity()};
label = optional<double>{std::numeric_limits<double>::infinity()};
} else {
label = {static_cast<double>(n)};
label = optional<double>{static_cast<double>(n)};
}
},
[&](int64_t n) {
if (n > std::numeric_limits<double>::max()) {
label = {std::numeric_limits<double>::infinity()};
label = optional<double>{std::numeric_limits<double>::infinity()};
} else {
label = {static_cast<double>(n)};
label = optional<double>{static_cast<double>(n)};
}
},
[&](double n) {
if (n > std::numeric_limits<double>::max()) {
label = {std::numeric_limits<double>::infinity()};
label = optional<double>{std::numeric_limits<double>::infinity()};
} else {
label = {static_cast<double>(n)};
label = optional<double>{n};
}
},
[&](const auto&) {}

View File

@@ -22,19 +22,19 @@ class GeometryCoordinates : public std::vector<GeometryCoordinate> {
public:
using coordinate_type = int16_t;
GeometryCoordinates() = default;
GeometryCoordinates(const std::vector<GeometryCoordinate>& v)
: std::vector<GeometryCoordinate>(v) {}
GeometryCoordinates(std::vector<GeometryCoordinate>&& v)
: std::vector<GeometryCoordinate>(std::move(v)) {}
using std::vector<GeometryCoordinate>::vector;
template <class... Args>
GeometryCoordinates(Args&&... args) : std::vector<GeometryCoordinate>(std::forward<Args>(args)...) {}
GeometryCoordinates(std::initializer_list<GeometryCoordinate> args)
: std::vector<GeometryCoordinate>(std::move(args)) {}
};
class GeometryCollection : public std::vector<GeometryCoordinates> {
public:
using coordinate_type = int16_t;
using std::vector<GeometryCoordinates>::vector;
template <class... Args>
GeometryCollection(Args&&... args) : std::vector<GeometryCoordinates>(std::forward<Args>(args)...) {}
GeometryCollection(std::initializer_list<GeometryCoordinates> args)
: std::vector<GeometryCoordinates>(std::move(args)) {}
};
class GeometryTileFeature {

View File

@@ -35,7 +35,7 @@ TEST(API, RecycleMapUpdateImages) {
auto loadStyle = [&](auto markerName, auto markerPath) {
auto source = std::make_unique<GeoJSONSource>("geometry");
source->setGeoJSON({ Point<double> { 0, 0 } });
source->setGeoJSON( Geometry<double>{ Point<double>{ 0, 0 } } );
auto layer = std::make_unique<SymbolLayer>("geometry", "geometry");
layer->setIconImage({ markerName });