Skip to content

Commit

Permalink
Getting geometry.hpp works with Visual Studio 2015.
Browse files Browse the repository at this point in the history
  • Loading branch information
lygstate committed Mar 9, 2017
1 parent 12aae69 commit 0edcf0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
23 changes: 14 additions & 9 deletions geometry.hpp/include/mapbox/geometry/feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace mapbox {
namespace geometry {

struct value;

struct null_value_t
{
constexpr null_value_t() {}
Expand All @@ -26,21 +24,28 @@ constexpr bool operator<(const null_value_t&, const null_value_t&) { return fals

constexpr null_value_t null_value = null_value_t();

struct property_vector;
struct property_map;
// Multiple numeric types (uint64_t, int64_t, double) are present in order to support
// the widest possible range of JSON numbers, which do not have a maximum range.
// Implementations that produce `value`s should use that order for type preference,
// using uint64_t for positive integers, int64_t for negative integers, and double
// for non-integers and integers outside the range of 64 bits.
using value_base = mapbox::util::variant<null_value_t, bool, uint64_t, int64_t, double, std::string,
mapbox::util::recursive_wrapper<std::vector<value>>,
mapbox::util::recursive_wrapper<std::unordered_map<std::string, value>>>;
using value = mapbox::util::variant<null_value_t, bool, uint64_t, int64_t, double, std::string,
property_vector, property_map>;

struct value : value_base
{
using value_base::value_base;
struct property_vector : public std::vector<value> {
using std::vector<value>::vector;
property_vector() : std::vector<value>(){};
property_vector(const std::vector<value> &_v): std::vector<value>(_v){}
};

using property_map = std::unordered_map<std::string, value>;
struct property_map : public std::unordered_map<std::string, value> {
using std::unordered_map<std::string, value>::unordered_map;
property_map() : std::unordered_map<std::string, value>() {}
property_map(const std::unordered_map<std::string, value> &_v): std::unordered_map<std::string, value>(_v) {}
property_map(std::unordered_map<std::string, value> &&_v) : std::unordered_map<std::string, value>(_v) {}
};

// The same considerations and requirement for numeric types apply as for `value_base`.
using identifier = mapbox::util::variant<null_value_t, uint64_t, int64_t, double, std::string>;
Expand Down
15 changes: 1 addition & 14 deletions geometry.hpp/include/mapbox/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,14 @@ template <typename T, template <typename...> class Cont = std::vector>
struct geometry_collection;

template <typename T>
using geometry_base = mapbox::util::variant<point<T>,
using geometry = mapbox::util::variant<point<T>,
line_string<T>,
polygon<T>,
multi_point<T>,
multi_line_string<T>,
multi_polygon<T>,
geometry_collection<T>>;

template <typename T>
struct geometry : geometry_base<T>
{
using coordinate_type = T;
using geometry_base<T>::geometry_base;

/*
* The default constructor would create a point geometry with default-constructed coordinates;
* i.e. (0, 0). Since this is not particularly useful, and could hide bugs, it is disabled.
*/
geometry() = delete;
};

template <typename T, template <typename...> class Cont>
struct geometry_collection : Cont<geometry<T>>
{
Expand Down

0 comments on commit 0edcf0a

Please sign in to comment.