Use std::variant instead of mapbox::util::variant (#6903)
This commit is contained in:
committed by
GitHub
parent
01b1673c8a
commit
c1ed73126d
@@ -29,7 +29,7 @@ struct V8Renderer
|
||||
for (const auto &keyValue : object.values)
|
||||
{
|
||||
Napi::Value child;
|
||||
mapbox::util::apply_visitor(V8Renderer(env, child), keyValue.second);
|
||||
std::visit(V8Renderer(env, child), keyValue.second);
|
||||
obj.Set(keyValue.first, child);
|
||||
}
|
||||
out = obj;
|
||||
@@ -41,7 +41,7 @@ struct V8Renderer
|
||||
for (auto i = 0u; i < array.values.size(); ++i)
|
||||
{
|
||||
Napi::Value child;
|
||||
mapbox::util::apply_visitor(V8Renderer(env, child), array.values[i]);
|
||||
std::visit(V8Renderer(env, child), array.values[i]);
|
||||
a.Set(i, child);
|
||||
}
|
||||
out = a;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include <exception>
|
||||
@@ -50,7 +51,7 @@ struct PluginParameters
|
||||
bool renderToBuffer = false;
|
||||
};
|
||||
|
||||
using ObjectOrString = typename mapbox::util::variant<osrm::json::Object, std::string>;
|
||||
using ObjectOrString = typename std::variant<osrm::json::Object, std::string>;
|
||||
|
||||
template <typename ResultT> inline Napi::Value render(const Napi::Env &env, const ResultT &result);
|
||||
|
||||
@@ -61,18 +62,18 @@ template <> Napi::Value inline render(const Napi::Env &env, const std::string &r
|
||||
|
||||
template <> Napi::Value inline render(const Napi::Env &env, const ObjectOrString &result)
|
||||
{
|
||||
if (result.is<osrm::json::Object>())
|
||||
if (std::holds_alternative<osrm::json::Object>(result))
|
||||
{
|
||||
// Convert osrm::json object tree into matching v8 object tree
|
||||
Napi::Value value;
|
||||
renderToV8(env, value, result.get<osrm::json::Object>());
|
||||
renderToV8(env, value, std::get<osrm::json::Object>(result));
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return the string object as a node Buffer
|
||||
return Napi::Buffer<char>::Copy(
|
||||
env, result.get<std::string>().data(), result.get<std::string>().size());
|
||||
env, std::get<std::string>(result).data(), std::get<std::string>(result).size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ inline void ParseResult(const osrm::Status &result_status, osrm::json::Object &r
|
||||
|
||||
if (result_status == osrm::Status::Error)
|
||||
{
|
||||
throw std::logic_error(code_iter->second.get<osrm::json::String>().value.c_str());
|
||||
throw std::logic_error(std::get<osrm::json::String>(code_iter->second).value.c_str());
|
||||
}
|
||||
|
||||
result.values.erase(code_iter);
|
||||
|
||||
Reference in New Issue
Block a user