replace boost::variant w/ mapbox::util::variant
This commit is contained in:
parent
b310e0f718
commit
7d2c627ad2
@ -30,9 +30,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef JSON_CONTAINER_H
|
||||
#define JSON_CONTAINER_H
|
||||
|
||||
#include "../ThirdParty/variant/variant.hpp"
|
||||
#include "../Util/StringUtil.h"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
// #include <boost/variant.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@ -42,21 +43,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace JSON
|
||||
{
|
||||
|
||||
struct String;
|
||||
struct Number;
|
||||
// struct String;
|
||||
// struct Number;
|
||||
struct Object;
|
||||
struct Array;
|
||||
struct True;
|
||||
struct False;
|
||||
struct Null;
|
||||
// struct True;
|
||||
// struct False;
|
||||
// struct Null;
|
||||
|
||||
typedef boost::variant<boost::recursive_wrapper<String>,
|
||||
boost::recursive_wrapper<Number>,
|
||||
boost::recursive_wrapper<Object>,
|
||||
boost::recursive_wrapper<Array>,
|
||||
boost::recursive_wrapper<True>,
|
||||
boost::recursive_wrapper<False>,
|
||||
boost::recursive_wrapper<Null> > Value;
|
||||
|
||||
struct String
|
||||
{
|
||||
@ -73,16 +67,6 @@ struct Number
|
||||
double value;
|
||||
};
|
||||
|
||||
struct Object
|
||||
{
|
||||
std::unordered_map<std::string, Value> values;
|
||||
};
|
||||
|
||||
struct Array
|
||||
{
|
||||
std::vector<Value> values;
|
||||
};
|
||||
|
||||
struct True
|
||||
{
|
||||
};
|
||||
@ -95,7 +79,25 @@ struct Null
|
||||
{
|
||||
};
|
||||
|
||||
struct Renderer : boost::static_visitor<>
|
||||
typedef mapbox::util::variant<String,
|
||||
Number,
|
||||
mapbox::util::recursive_wrapper<Object>,
|
||||
mapbox::util::recursive_wrapper<Array>,
|
||||
True,
|
||||
False,
|
||||
Null > Value;
|
||||
|
||||
struct Object
|
||||
{
|
||||
std::unordered_map<std::string, Value> values;
|
||||
};
|
||||
|
||||
struct Array
|
||||
{
|
||||
std::vector<Value> values;
|
||||
};
|
||||
|
||||
struct Renderer : mapbox::util::static_visitor<>
|
||||
{
|
||||
Renderer(std::ostream &_out) : out(_out) {}
|
||||
|
||||
@ -114,7 +116,7 @@ struct Renderer : boost::static_visitor<>
|
||||
while (iterator != object.values.end())
|
||||
{
|
||||
out << "\"" << (*iterator).first << "\":";
|
||||
boost::apply_visitor(Renderer(out), (*iterator).second);
|
||||
mapbox::util::apply_visitor(Renderer(out), (*iterator).second);
|
||||
if (++iterator != object.values.end())
|
||||
{
|
||||
out << ",";
|
||||
@ -130,7 +132,7 @@ struct Renderer : boost::static_visitor<>
|
||||
iterator = array.values.begin();
|
||||
while (iterator != array.values.end())
|
||||
{
|
||||
boost::apply_visitor(Renderer(out), *iterator);
|
||||
mapbox::util::apply_visitor(Renderer(out), *iterator);
|
||||
if (++iterator != array.values.end())
|
||||
{
|
||||
out << ",";
|
||||
@ -149,7 +151,7 @@ struct Renderer : boost::static_visitor<>
|
||||
std::ostream &out;
|
||||
};
|
||||
|
||||
struct ArrayRenderer : boost::static_visitor<>
|
||||
struct ArrayRenderer : mapbox::util::static_visitor<>
|
||||
{
|
||||
ArrayRenderer(std::vector<char> &_out) : out(_out) {}
|
||||
|
||||
@ -176,7 +178,7 @@ struct ArrayRenderer : boost::static_visitor<>
|
||||
out.push_back('\"');
|
||||
out.push_back(':');
|
||||
|
||||
boost::apply_visitor(ArrayRenderer(out), (*iterator).second);
|
||||
mapbox::util::apply_visitor(ArrayRenderer(out), (*iterator).second);
|
||||
if (++iterator != object.values.end())
|
||||
{
|
||||
out.push_back(',');
|
||||
@ -192,7 +194,7 @@ struct ArrayRenderer : boost::static_visitor<>
|
||||
iterator = array.values.begin();
|
||||
while (iterator != array.values.end())
|
||||
{
|
||||
boost::apply_visitor(ArrayRenderer(out), *iterator);
|
||||
mapbox::util::apply_visitor(ArrayRenderer(out), *iterator);
|
||||
if (++iterator != array.values.end())
|
||||
{
|
||||
out.push_back(',');
|
||||
@ -223,13 +225,13 @@ struct ArrayRenderer : boost::static_visitor<>
|
||||
inline void render(std::ostream &out, const Object &object)
|
||||
{
|
||||
Value value = object;
|
||||
boost::apply_visitor(Renderer(out), value);
|
||||
mapbox::util::apply_visitor(Renderer(out), value);
|
||||
}
|
||||
|
||||
inline void render(std::vector<char> &out, const Object &object)
|
||||
{
|
||||
Value value = object;
|
||||
boost::apply_visitor(ArrayRenderer(out), value);
|
||||
mapbox::util::apply_visitor(ArrayRenderer(out), value);
|
||||
}
|
||||
|
||||
} // namespace JSON
|
||||
|
@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "SharedMemoryFactory.h"
|
||||
#include "SharedMemoryVectorWrapper.h"
|
||||
|
||||
#include "../ThirdParty/variant/variant.hpp"
|
||||
#include "../Util/MercatorUtil.h"
|
||||
#include "../Util/NumericUtil.h"
|
||||
#include "../Util/OSRMException.h"
|
||||
@ -48,7 +49,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
// #include <boost/variant.hpp>
|
||||
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/parallel_sort.h>
|
||||
@ -307,7 +308,7 @@ class StaticRTree
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<TreeNode, EdgeDataT> IncrementalQueryNodeType;
|
||||
typedef mapbox::util::variant<TreeNode, EdgeDataT> IncrementalQueryNodeType;
|
||||
struct IncrementalQueryCandidate
|
||||
{
|
||||
explicit IncrementalQueryCandidate(const float dist, const IncrementalQueryNodeType &node)
|
||||
@ -323,23 +324,23 @@ class StaticRTree
|
||||
return other.min_dist < min_dist;
|
||||
}
|
||||
|
||||
inline bool RepresentsTreeNode() const
|
||||
{
|
||||
return boost::apply_visitor(decide_type_visitor(), node);
|
||||
}
|
||||
// inline bool RepresentsTreeNode() const
|
||||
// {
|
||||
// return mapbox::util::apply_visitor(decide_type_visitor(), node);
|
||||
// }
|
||||
|
||||
float min_dist;
|
||||
IncrementalQueryNodeType node;
|
||||
|
||||
private:
|
||||
class decide_type_visitor : public boost::static_visitor<bool>
|
||||
{
|
||||
public:
|
||||
bool operator()(const TreeNode &) const { return true; }
|
||||
// private:
|
||||
// class decide_type_visitor : public mapbox::util::static_visitor<bool>
|
||||
// {
|
||||
// public:
|
||||
// bool operator()(const TreeNode &) const { return true; }
|
||||
|
||||
template<typename AnotherType>
|
||||
bool operator()(const AnotherType &) const { return false; }
|
||||
};
|
||||
// template<typename AnotherType>
|
||||
// bool operator()(const AnotherType &) const { return false; }
|
||||
// };
|
||||
};
|
||||
|
||||
typename ShM<TreeNode, UseSharedMemory>::vector m_search_tree;
|
||||
@ -700,9 +701,9 @@ class StaticRTree
|
||||
continue;
|
||||
}
|
||||
|
||||
if (current_query_node.RepresentsTreeNode())
|
||||
if (current_query_node.node.template is<TreeNode>())
|
||||
{
|
||||
const TreeNode & current_tree_node = boost::get<TreeNode>(current_query_node.node);
|
||||
const TreeNode & current_tree_node = current_query_node.node.template get<TreeNode>();
|
||||
if (current_tree_node.child_is_on_disk)
|
||||
{
|
||||
++loaded_leafs;
|
||||
@ -775,7 +776,7 @@ class StaticRTree
|
||||
{
|
||||
++inspected_segments;
|
||||
// inspecting an actual road segment
|
||||
const EdgeDataT & current_segment = boost::get<EdgeDataT>(current_query_node.node);
|
||||
const EdgeDataT & current_segment = current_query_node.node.template get<EdgeDataT>();
|
||||
|
||||
// don't collect too many results from small components
|
||||
if (number_of_results_found_in_big_cc == number_of_results && !current_segment.is_in_tiny_cc)
|
||||
|
Loading…
Reference in New Issue
Block a user