Merge remote-tracking branch 'origin/master' into dl_using_keyword

This commit is contained in:
Dennis Luxen
2022-12-10 16:02:53 +01:00
45 changed files with 951 additions and 1059 deletions
+4 -4
View File
@@ -57,8 +57,8 @@ class BaseAPI
{
// TODO: check forward/reverse
const auto toName = [this](const auto &phantom) {
return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
.to_string();
return std::string(
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)));
};
const auto noEmpty = [](const auto &name) { return !name.empty(); };
@@ -128,8 +128,8 @@ class BaseAPI
static_cast<float>(static_cast<double>(util::toFloating(snapped_location.lat))));
const auto toName = [this](const auto &phantom) {
return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
.to_string();
return std::string(
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)));
};
const auto noEmpty = [](const auto &name) { return !name.empty(); };
@@ -142,7 +142,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
extractor::Datasources *m_datasources;
std::uint32_t m_check_sum;
StringView m_data_timestamp;
std::string_view m_data_timestamp;
util::vector_view<util::Coordinate> m_coordinate_list;
extractor::PackedOSMIDsView m_osmnodeid_list;
util::vector_view<std::uint32_t> m_lane_description_offsets;
@@ -408,32 +408,32 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return edge_based_node_data.GetNameID(edge_based_node_id);
}
StringView GetNameForID(const NameID id) const override final
std::string_view GetNameForID(const NameID id) const override final
{
return m_name_table.GetNameForID(id);
}
StringView GetRefForID(const NameID id) const override final
std::string_view GetRefForID(const NameID id) const override final
{
return m_name_table.GetRefForID(id);
}
StringView GetPronunciationForID(const NameID id) const override final
std::string_view GetPronunciationForID(const NameID id) const override final
{
return m_name_table.GetPronunciationForID(id);
}
StringView GetDestinationsForID(const NameID id) const override final
std::string_view GetDestinationsForID(const NameID id) const override final
{
return m_name_table.GetDestinationsForID(id);
}
StringView GetExitsForID(const NameID id) const override final
std::string_view GetExitsForID(const NameID id) const override final
{
return m_name_table.GetExitsForID(id);
}
StringView GetDatasourceName(const DatasourceID id) const override final
std::string_view GetDatasourceName(const DatasourceID id) const override final
{
return m_datasources->GetSourceName(id);
}
@@ -26,7 +26,6 @@
#include "util/integer_range.hpp"
#include "util/packed_vector.hpp"
#include "util/string_util.hpp"
#include "util/string_view.hpp"
#include "util/typedefs.hpp"
#include "osrm/coordinate.hpp"
@@ -37,6 +36,7 @@
#include <engine/bearing.hpp>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -47,8 +47,6 @@ namespace engine
namespace datafacade
{
using StringView = util::StringView;
class BaseDataFacade
{
public:
@@ -113,7 +111,7 @@ class BaseDataFacade
GetUncompressedReverseDatasources(const PackedGeometryID id) const = 0;
// Gets the name of a datasource
virtual StringView GetDatasourceName(const DatasourceID id) const = 0;
virtual std::string_view GetDatasourceName(const DatasourceID id) const = 0;
virtual osrm::guidance::TurnInstruction
GetTurnInstructionForEdgeID(const EdgeID edge_based_edge_id) const = 0;
@@ -157,15 +155,15 @@ class BaseDataFacade
virtual NameID GetNameIndex(const NodeID edge_based_node_id) const = 0;
virtual StringView GetNameForID(const NameID id) const = 0;
virtual std::string_view GetNameForID(const NameID id) const = 0;
virtual StringView GetRefForID(const NameID id) const = 0;
virtual std::string_view GetRefForID(const NameID id) const = 0;
virtual StringView GetPronunciationForID(const NameID id) const = 0;
virtual std::string_view GetPronunciationForID(const NameID id) const = 0;
virtual StringView GetDestinationsForID(const NameID id) const = 0;
virtual std::string_view GetDestinationsForID(const NameID id) const = 0;
virtual StringView GetExitsForID(const NameID id) const = 0;
virtual std::string_view GetExitsForID(const NameID id) const = 0;
virtual bool GetContinueStraightDefault() const = 0;
+2 -2
View File
@@ -145,11 +145,11 @@ inline std::string assembleSummary(const datafacade::BaseDataFacade &facade,
const auto name_id_to_string = [&](const NameID name_id) {
const auto name = facade.GetNameForID(name_id);
if (!name.empty())
return name.to_string();
return std::string(name);
else
{
const auto ref = facade.GetRefForID(name_id);
return ref.to_string();
return std::string(ref);
}
};
+20 -20
View File
@@ -140,11 +140,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{path_point.from_edge_based_node,
step_name_id,
is_segregated,
name.to_string(),
ref.to_string(),
pronunciation.to_string(),
destinations.to_string(),
exits.to_string(),
std::string(name),
std::string(ref),
std::string(pronunciation),
std::string(destinations),
std::string(exits),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
from_alias<double>(segment_duration) / 10.,
@@ -241,11 +241,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{leg_data[leg_data.size() - 1].from_edge_based_node,
step_name_id,
is_segregated,
facade.GetNameForID(step_name_id).to_string(),
facade.GetRefForID(step_name_id).to_string(),
facade.GetPronunciationForID(step_name_id).to_string(),
facade.GetDestinationsForID(step_name_id).to_string(),
facade.GetExitsForID(step_name_id).to_string(),
std::string(facade.GetNameForID(step_name_id)),
std::string(facade.GetRefForID(step_name_id)),
std::string(facade.GetPronunciationForID(step_name_id)),
std::string(facade.GetDestinationsForID(step_name_id)),
std::string(facade.GetExitsForID(step_name_id)),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
from_alias<double>(duration) / 10.,
@@ -287,11 +287,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{source_node_id,
source_name_id,
is_segregated,
facade.GetNameForID(source_name_id).to_string(),
facade.GetRefForID(source_name_id).to_string(),
facade.GetPronunciationForID(source_name_id).to_string(),
facade.GetDestinationsForID(source_name_id).to_string(),
facade.GetExitsForID(source_name_id).to_string(),
std::string(facade.GetNameForID(source_name_id)),
std::string(facade.GetRefForID(source_name_id)),
std::string(facade.GetPronunciationForID(source_name_id)),
std::string(facade.GetDestinationsForID(source_name_id)),
std::string(facade.GetExitsForID(source_name_id)),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
from_alias<double>(duration) / 10.,
@@ -330,11 +330,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{target_node_id,
target_name_id,
facade.IsSegregated(target_node_id),
facade.GetNameForID(target_name_id).to_string(),
facade.GetRefForID(target_name_id).to_string(),
facade.GetPronunciationForID(target_name_id).to_string(),
facade.GetDestinationsForID(target_name_id).to_string(),
facade.GetExitsForID(target_name_id).to_string(),
std::string(facade.GetNameForID(target_name_id)),
std::string(facade.GetRefForID(target_name_id)),
std::string(facade.GetPronunciationForID(target_name_id)),
std::string(facade.GetDestinationsForID(target_name_id)),
std::string(facade.GetExitsForID(target_name_id)),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
ZERO_DURATION,
+7 -4
View File
@@ -1,9 +1,12 @@
#ifndef OSRM_EXTRACT_DATASOURCES_HPP
#define OSRM_EXTRACT_DATASOURCES_HPP
#include "util/typedefs.hpp"
#include <algorithm>
#include <array>
#include <cstdint>
#include <util/string_view.hpp>
#include <util/typedefs.hpp>
#include <string_view>
namespace osrm
{
@@ -22,11 +25,11 @@ class Datasources
std::fill(sources.begin(), sources.end(), '\0');
}
util::StringView GetSourceName(DatasourceID id) const
std::string_view GetSourceName(DatasourceID id) const
{
auto begin = sources.data() + (MAX_LENGTH_NAME * id);
return util::StringView{begin, lengths[id]};
return std::string_view{begin, lengths[id]};
}
void SetSourceName(DatasourceID id, const std::string &name)
+7 -7
View File
@@ -2,10 +2,10 @@
#define OSRM_EXTRACTOR_NAME_TABLE_HPP
#include "util/indexed_data.hpp"
#include "util/string_view.hpp"
#include "util/typedefs.hpp"
#include <string>
#include <string_view>
namespace osrm
{
@@ -50,7 +50,7 @@ template <storage::Ownership Ownership> class NameTableImpl
{
public:
using IndexedData =
util::detail::IndexedDataImpl<util::VariableGroupBlock<16, util::StringView>, Ownership>;
util::detail::IndexedDataImpl<util::VariableGroupBlock<16, std::string_view>, Ownership>;
using ResultType = typename IndexedData::ResultType;
using ValueType = typename IndexedData::ValueType;
@@ -58,7 +58,7 @@ template <storage::Ownership Ownership> class NameTableImpl
NameTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {}
util::StringView GetNameForID(const NameID id) const
std::string_view GetNameForID(const NameID id) const
{
if (id == INVALID_NAMEID)
return {};
@@ -66,7 +66,7 @@ template <storage::Ownership Ownership> class NameTableImpl
return indexed_data.at(id + 0);
}
util::StringView GetDestinationsForID(const NameID id) const
std::string_view GetDestinationsForID(const NameID id) const
{
if (id == INVALID_NAMEID)
return {};
@@ -74,7 +74,7 @@ template <storage::Ownership Ownership> class NameTableImpl
return indexed_data.at(id + 1);
}
util::StringView GetExitsForID(const NameID id) const
std::string_view GetExitsForID(const NameID id) const
{
if (id == INVALID_NAMEID)
return {};
@@ -82,7 +82,7 @@ template <storage::Ownership Ownership> class NameTableImpl
return indexed_data.at(id + 4);
}
util::StringView GetRefForID(const NameID id) const
std::string_view GetRefForID(const NameID id) const
{
if (id == INVALID_NAMEID)
return {};
@@ -91,7 +91,7 @@ template <storage::Ownership Ownership> class NameTableImpl
return indexed_data.at(id + OFFSET_REF);
}
util::StringView GetPronunciationForID(const NameID id) const
std::string_view GetPronunciationForID(const NameID id) const
{
if (id == INVALID_NAMEID)
return {};
+4 -4
View File
@@ -2,9 +2,9 @@
#define OSRM_EXTRACTOR_SUFFIX_LIST_HPP_
#include <string>
#include <string_view>
#include <unordered_set>
#include "util/string_view.hpp"
#include <vector>
namespace osrm
{
@@ -23,7 +23,7 @@ class SuffixTable final
// check whether a string is part of the know suffix list
bool isSuffix(const std::string &possible_suffix) const;
bool isSuffix(util::StringView possible_suffix) const;
bool isSuffix(std::string_view possible_suffix) const;
private:
// Store lower-cased strings in SuffixTable and a set of StringViews for quick membership
@@ -36,7 +36,7 @@ class SuffixTable final
// require us to first convert StringViews into strings (allocation), do the membership,
// and destroy the StringView again.
std::vector<std::string> suffixes;
std::unordered_set<util::StringView> suffix_set;
std::unordered_set<std::string_view> suffix_set;
};
} /* namespace extractor */
+22 -22
View File
@@ -2,11 +2,7 @@
#define OSRM_BINDINGS_NODE_JSON_V8_RENDERER_HPP
#include "osrm/json_container.hpp"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <nan.h>
#pragma GCC diagnostic pop
#include <napi.h>
#include <functional>
@@ -15,52 +11,56 @@ namespace node_osrm
struct V8Renderer
{
explicit V8Renderer(v8::Local<v8::Value> &_out) : out(_out) {}
explicit V8Renderer(const Napi::Env &env, Napi::Value &out) : env(env), out(out) {}
void operator()(const osrm::json::String &string) const
{
out = Nan::New(std::cref(string.value)).ToLocalChecked();
out = Napi::String::New(env, string.value);
}
void operator()(const osrm::json::Number &number) const { out = Nan::New(number.value); }
void operator()(const osrm::json::Number &number) const
{
out = Napi::Number::New(env, number.value);
}
void operator()(const osrm::json::Object &object) const
{
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
Napi::Object obj = Napi::Object::New(env);
for (const auto &keyValue : object.values)
{
v8::Local<v8::Value> child;
mapbox::util::apply_visitor(V8Renderer(child), keyValue.second);
Nan::Set(obj, Nan::New(keyValue.first).ToLocalChecked(), child);
Napi::Value child;
mapbox::util::apply_visitor(V8Renderer(env, child), keyValue.second);
obj.Set(keyValue.first, child);
}
out = obj;
}
void operator()(const osrm::json::Array &array) const
{
v8::Local<v8::Array> a = Nan::New<v8::Array>(array.values.size());
Napi::Array a = Napi::Array::New(env, array.values.size());
for (auto i = 0u; i < array.values.size(); ++i)
{
v8::Local<v8::Value> child;
mapbox::util::apply_visitor(V8Renderer(child), array.values[i]);
Nan::Set(a, i, child);
Napi::Value child;
mapbox::util::apply_visitor(V8Renderer(env, child), array.values[i]);
a.Set(i, child);
}
out = a;
}
void operator()(const osrm::json::True &) const { out = Nan::New(true); }
void operator()(const osrm::json::True &) const { out = Napi::Boolean::New(env, true); }
void operator()(const osrm::json::False &) const { out = Nan::New(false); }
void operator()(const osrm::json::False &) const { out = Napi::Boolean::New(env, false); }
void operator()(const osrm::json::Null &) const { out = Nan::Null(); }
void operator()(const osrm::json::Null &) const { out = env.Null(); }
private:
v8::Local<v8::Value> &out;
const Napi::Env &env;
Napi::Value &out;
};
inline void renderToV8(v8::Local<v8::Value> &out, const osrm::json::Object &object)
inline void renderToV8(const Napi::Env &env, Napi::Value &out, const osrm::json::Object &object)
{
V8Renderer renderer(out);
V8Renderer renderer(env, out);
renderer(object);
}
} // namespace node_osrm
+13 -28
View File
@@ -3,45 +3,30 @@
#include "osrm/osrm_fwd.hpp"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <nan.h>
#pragma GCC diagnostic pop
#include <napi.h>
#include <memory>
namespace node_osrm
{
struct Engine final : public Nan::ObjectWrap
class Engine final : public Napi::ObjectWrap<Engine>
{
using Base = Nan::ObjectWrap;
public:
static Napi::Object Init(Napi::Env env, Napi::Object exports);
Engine(const Napi::CallbackInfo &info);
static NAN_MODULE_INIT(Init);
static NAN_METHOD(New);
static NAN_METHOD(route);
static NAN_METHOD(nearest);
static NAN_METHOD(table);
static NAN_METHOD(tile);
static NAN_METHOD(match);
static NAN_METHOD(trip);
Engine(osrm::EngineConfig &config);
// Thread-safe singleton accessor
static Nan::Persistent<v8::Function> &constructor();
// Ref-counted OSRM alive even after shutdown until last callback is done
std::shared_ptr<osrm::OSRM> this_;
private:
Napi::Value route(const Napi::CallbackInfo &info);
Napi::Value nearest(const Napi::CallbackInfo &info);
Napi::Value table(const Napi::CallbackInfo &info);
Napi::Value tile(const Napi::CallbackInfo &info);
Napi::Value match(const Napi::CallbackInfo &info);
Napi::Value trip(const Napi::CallbackInfo &info);
};
} // namespace node_osrm
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
NAN_MODULE_WORKER_ENABLED(osrm, node_osrm::Engine::Init)
#pragma GCC diagnostic pop
#endif
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -10,8 +10,8 @@
#include "storage/tar.hpp"
#include <boost/assert.hpp>
#include <boost/function_output_iterator.hpp>
#include <boost/iterator/function_input_iterator.hpp>
#include <boost/iterator/function_output_iterator.hpp>
#include <cmath>
#include <cstdint>
+1 -1
View File
@@ -3,7 +3,7 @@
#include "storage/shared_datatype.hpp"
#include <boost/function_output_iterator.hpp>
#include <boost/iterator/function_output_iterator.hpp>
#include <type_traits>
#include <unordered_map>
+1 -1
View File
@@ -263,7 +263,7 @@ inline auto make_partition_view(const SharedDataIndex &index, const std::string
inline auto make_timestamp_view(const SharedDataIndex &index, const std::string &name)
{
return util::StringView(index.GetBlockPtr<char>(name), index.GetBlockEntries(name));
return std::string_view(index.GetBlockPtr<char>(name), index.GetBlockEntries(name));
}
inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name)
+1 -1
View File
@@ -78,7 +78,7 @@ template <typename Key, typename Value> struct CSVFilesParser
util::Log() << "In total loaded " << csv_filenames.size() << " file(s) with a total of "
<< lookup.size() << " unique values";
return LookupTable<Key, Value>{lookup};
return LookupTable<Key, Value>{std::move(lookup)};
}
catch (const std::exception &e)
// TBB should capture to std::exception_ptr and automatically rethrow in this thread.
-22
View File
@@ -1,22 +0,0 @@
#ifndef CONTAINER_HPP
#define CONTAINER_HPP
#include <utility>
namespace osrm
{
namespace util
{
template <class Container> void append_to_container(Container &&) {}
template <class Container, typename T, typename... Args>
void append_to_container(Container &&container, T value, Args &&... args)
{
container.emplace_back(value);
append_to_container(std::forward<Container>(container), std::forward<Args>(args)...);
}
} // namespace util
} // namespace osrm
#endif
+28 -24
View File
@@ -27,8 +27,8 @@ namespace guidance
// Name Change Logic
// Used both during Extraction as well as during Post-Processing
inline util::StringView longest_common_substring(const util::StringView &lhs,
const util::StringView &rhs)
inline std::string_view longest_common_substring(const std::string_view lhs,
const std::string_view rhs)
{
if (lhs.empty() || rhs.empty())
return "";
@@ -70,7 +70,11 @@ template <typename StringView> inline auto decompose(const StringView &lhs, cons
const auto trim = [](StringView view) {
// we compare suffixes based on this value, it might break UTF chars, but as long as we are
// consistent in handling, we do not create bad results
std::string str = boost::to_lower_copy(view.to_string());
std::string str;
str.reserve(view.size());
std::transform(view.begin(), view.end(), std::back_inserter(str), [](unsigned char c) {
return std::tolower(c);
});
auto front = str.find_first_not_of(' ');
if (front == std::string::npos)
@@ -129,20 +133,20 @@ inline bool requiresNameAnnounced(const StringView &from_name,
const auto name_is_contained =
boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name);
const auto checkForPrefixOrSuffixChange =
[](const StringView &first, const StringView &second, const SuffixTable &suffix_table) {
std::string first_prefix, first_suffix, second_prefix, second_suffix;
std::tie(first_prefix, first_suffix, second_prefix, second_suffix) =
decompose(first, second);
const auto checkTable = [&](const std::string &str) {
return str.empty() || suffix_table.isSuffix(str);
};
return checkTable(first_prefix) && checkTable(first_suffix) &&
checkTable(second_prefix) && checkTable(second_suffix);
const auto checkForPrefixOrSuffixChange = [](const std::string_view first,
const std::string_view second,
const SuffixTable &suffix_table) {
std::string first_prefix, first_suffix, second_prefix, second_suffix;
std::tie(first_prefix, first_suffix, second_prefix, second_suffix) =
decompose(first, second);
const auto checkTable = [&](const std::string &str) {
return str.empty() || suffix_table.isSuffix(str);
};
return checkTable(first_prefix) && checkTable(first_suffix) && checkTable(second_prefix) &&
checkTable(second_suffix);
};
const auto is_suffix_change = checkForPrefixOrSuffixChange(from_name, to_name, suffix_table);
const auto names_are_equal = from_name == to_name || name_is_contained || is_suffix_change;
const auto name_is_removed = !from_name.empty() && to_name.empty();
@@ -201,17 +205,17 @@ inline bool requiresNameAnnounced(const std::string &from_name,
struct NopSuffixTable final
{
NopSuffixTable() {}
bool isSuffix(const StringView &) const { return false; }
bool isSuffix(const std::string_view) const { return false; }
} static const table;
return requiresNameAnnounced(util::StringView(from_name),
util::StringView(from_ref),
util::StringView(from_pronunciation),
util::StringView(from_exits),
util::StringView(to_name),
util::StringView(to_ref),
util::StringView(to_pronunciation),
util::StringView(to_exits),
return requiresNameAnnounced(std::string_view(from_name),
std::string_view(from_ref),
std::string_view(from_pronunciation),
std::string_view(from_exits),
std::string_view(to_name),
std::string_view(to_ref),
std::string_view(to_pronunciation),
std::string_view(to_exits),
table);
}
+5 -5
View File
@@ -4,16 +4,16 @@
#include "storage/tar_fwd.hpp"
#include "util/exception.hpp"
#include "util/string_view.hpp"
#include "util/vector_view.hpp"
#include <boost/assert.hpp>
#include <boost/function_output_iterator.hpp>
#include <boost/iterator/function_output_iterator.hpp>
#include <array>
#include <iterator>
#include <limits>
#include <string>
#include <string_view>
#include <type_traits>
namespace osrm
@@ -216,7 +216,7 @@ template <int N, typename T = std::string> struct FixedGroupBlock
std::numeric_limits<std::make_unsigned_t<ValueType>>::max();
auto index = 0;
std::array<ValueType, BLOCK_SIZE> prefix;
std::array<ValueType, BLOCK_SIZE> prefix{};
for (OffsetIterator curr = first, next = std::next(first); curr != last; ++curr, ++next)
{
@@ -365,14 +365,14 @@ template <typename GroupBlockPolicy, storage::Ownership Ownership> struct Indexe
std::enable_if_t<std::is_same<T, typename std::iterator_traits<Iter>::value_type>::value>;
template <typename T = ResultType, typename Iter, typename = IsValueIterator<Iter, ValueType>>
typename std::enable_if<!std::is_same<T, StringView>::value, T>::type
typename std::enable_if<!std::is_same<T, std::string_view>::value, T>::type
adapt(const Iter first, const Iter last) const
{
return ResultType(first, last);
}
template <typename T = ResultType, typename Iter, typename = IsValueIterator<Iter, ValueType>>
typename std::enable_if<std::is_same<T, StringView>::value, T>::type
typename std::enable_if<std::is_same<T, std::string_view>::value, T>::type
adapt(const Iter first, const Iter last) const
{
auto diff = std::distance(first, last);
-25
View File
@@ -2,7 +2,6 @@
#define JSON_UTIL_HPP
#include "osrm/json_container.hpp"
#include "util/container.hpp"
#include <cmath>
#include <limits>
@@ -27,30 +26,6 @@ template <typename T> T clamp_float(T d)
return d;
}
template <typename... Args> Array make_array(Args... args)
{
Array a;
// TODO: check why a.values.emplace_back(args...); is not an option here
append_to_container(a.values, args...);
return a;
}
// Easy acces to object hierachies
inline Value &get(Value &value) { return value; }
template <typename... Keys> Value &get(Value &value, const char *key, Keys... keys)
{
using recursive_object_t = mapbox::util::recursive_wrapper<Object>;
return get(value.get<recursive_object_t>().get().values[key], keys...);
}
template <typename... Keys> Value &get(Value &value, unsigned key, Keys... keys)
{
using recursive_array_t = mapbox::util::recursive_wrapper<Array>;
return get(value.get<recursive_array_t>().get().values[key], keys...);
}
} // namespace json
} // namespace util
} // namespace osrm
-34
View File
@@ -1,34 +0,0 @@
#ifndef OSRM_STRING_VIEW_HPP
#define OSRM_STRING_VIEW_HPP
#include <boost/functional/hash.hpp>
#include <boost/utility/string_ref.hpp>
namespace osrm
{
namespace util
{
// Convenience typedef: boost::string_ref, boost::string_view or C++17's string_view
using StringView = boost::string_ref;
} // namespace util
} // namespace osrm
// Specializing hash<> for user-defined type in std namespace, this is standard conforming.
namespace std
{
template <> struct hash<::osrm::util::StringView> final
{
std::size_t operator()(::osrm::util::StringView v) const noexcept
{
// Bring into scope and call un-qualified for ADL:
// remember we want to be able to switch impl. above.
using std::begin;
using std::end;
return boost::hash_range(begin(v), end(v));
}
};
} // namespace std
#endif /* OSRM_STRING_VIEW_HPP */