Use std::variant instead of mapbox::util::variant (#6903)
This commit is contained in:
committed by
GitHub
parent
01b1673c8a
commit
c1ed73126d
@@ -51,7 +51,7 @@ class GeojsonLogger
|
||||
if (!first)
|
||||
ofs << ",\n\t\t";
|
||||
|
||||
util::json::render(ofs, object.get<util::json::Object>());
|
||||
util::json::render(ofs, std::get<util::json::Object>(object));
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
@@ -51,4 +51,4 @@ struct CoordinateVectorToMultiPoint
|
||||
|
||||
} // namespace osrm::util
|
||||
|
||||
#endif /* OSRM_GEOJSON_DEBUG_POLICIES */
|
||||
#endif /* OSRM_GEOJSON_DEBUG_POLICIES */
|
||||
@@ -55,12 +55,12 @@ inline util::json::Object makeStyle(const GeojsonStyleSize size_type,
|
||||
|
||||
struct CoordinateToJsonArray
|
||||
{
|
||||
util::json::Array operator()(const util::Coordinate coordinate)
|
||||
util::json::Value operator()(const util::Coordinate coordinate)
|
||||
{
|
||||
util::json::Array json_coordinate;
|
||||
json_coordinate.values.push_back(static_cast<double>(toFloating(coordinate.lon)));
|
||||
json_coordinate.values.push_back(static_cast<double>(toFloating(coordinate.lat)));
|
||||
return json_coordinate;
|
||||
return util::json::Value{json_coordinate};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ struct NodeIdToCoordinate
|
||||
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
|
||||
util::json::Array operator()(const NodeID nid)
|
||||
util::json::Value operator()(const NodeID nid)
|
||||
{
|
||||
auto coordinate = node_coordinates[nid];
|
||||
CoordinateToJsonArray converter;
|
||||
@@ -108,4 +108,4 @@ inline util::json::Array makeJsonArray(const std::vector<util::Coordinate> &inpu
|
||||
}
|
||||
} // namespace osrm::util
|
||||
|
||||
#endif /* OSRM_GEOJSON_DEBUG_POLICY_TOOLKIT_HPP */
|
||||
#endif /* OSRM_GEOJSON_DEBUG_POLICY_TOOLKIT_HPP */
|
||||
@@ -31,11 +31,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef JSON_CONTAINER_HPP
|
||||
#define JSON_CONTAINER_HPP
|
||||
|
||||
#include <mapbox/variant.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm::util::json
|
||||
@@ -96,13 +95,7 @@ struct Null
|
||||
*
|
||||
* Dispatch on its type by either by using apply_visitor or its get function.
|
||||
*/
|
||||
using Value = mapbox::util::variant<String,
|
||||
Number,
|
||||
mapbox::util::recursive_wrapper<Object>,
|
||||
mapbox::util::recursive_wrapper<Array>,
|
||||
True,
|
||||
False,
|
||||
Null>;
|
||||
using Value = std::variant<String, Number, Object, Array, True, False, Null>;
|
||||
|
||||
/**
|
||||
* Typed Object.
|
||||
|
||||
@@ -81,10 +81,10 @@ struct Comparator
|
||||
|
||||
const auto &rhs_child = rhs.values.find(key)->second;
|
||||
const auto &lhs_child = lhs.values.find(key)->second;
|
||||
auto is_same = mapbox::util::apply_visitor(
|
||||
Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
|
||||
lhs_child,
|
||||
rhs_child);
|
||||
auto is_same =
|
||||
std::visit(Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
|
||||
lhs_child,
|
||||
rhs_child);
|
||||
if (!is_same)
|
||||
{
|
||||
return false;
|
||||
@@ -104,12 +104,11 @@ struct Comparator
|
||||
|
||||
for (auto i = 0UL; i < lhs.values.size(); ++i)
|
||||
{
|
||||
auto is_same =
|
||||
mapbox::util::apply_visitor(Comparator(reason,
|
||||
lhs_path + "[" + std::to_string(i) + "]",
|
||||
rhs_path + "[" + std::to_string(i) + "]"),
|
||||
lhs.values[i],
|
||||
rhs.values[i]);
|
||||
auto is_same = std::visit(Comparator(reason,
|
||||
lhs_path + "[" + std::to_string(i) + "]",
|
||||
rhs_path + "[" + std::to_string(i) + "]"),
|
||||
lhs.values[i],
|
||||
rhs.values[i]);
|
||||
if (!is_same)
|
||||
{
|
||||
return false;
|
||||
@@ -151,8 +150,7 @@ struct Comparator
|
||||
|
||||
inline bool compare(const Value &reference, const Value &result, std::string &reason)
|
||||
{
|
||||
return mapbox::util::apply_visitor(
|
||||
Comparator(reason, "reference", "result"), reference, result);
|
||||
return std::visit(Comparator(reason, "reference", "result"), reference, result);
|
||||
}
|
||||
} // namespace osrm::util::json
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ template <typename Out> struct Renderer
|
||||
write('\"');
|
||||
write(it->first);
|
||||
write<>("\":");
|
||||
mapbox::util::apply_visitor(Renderer(out), it->second);
|
||||
std::visit(Renderer(out), it->second);
|
||||
if (++it != end)
|
||||
{
|
||||
write(',');
|
||||
@@ -81,7 +81,7 @@ template <typename Out> struct Renderer
|
||||
write('[');
|
||||
for (auto it = array.values.cbegin(), end = array.values.cend(); it != end;)
|
||||
{
|
||||
mapbox::util::apply_visitor(Renderer(out), *it);
|
||||
std::visit(Renderer(out), *it);
|
||||
if (++it != end)
|
||||
{
|
||||
write(',');
|
||||
|
||||
Reference in New Issue
Block a user