diff --git a/include/engine/datafacade/shared_datafacade.hpp b/include/engine/datafacade/shared_datafacade.hpp index 73b345661..fa2766d7c 100644 --- a/include/engine/datafacade/shared_datafacade.hpp +++ b/include/engine/datafacade/shared_datafacade.hpp @@ -16,7 +16,6 @@ #include "util/guidance/turn_lanes.hpp" #include "engine/geospatial_query.hpp" -#include "util/make_unique.hpp" #include "util/range_table.hpp" #include "util/rectangle.hpp" #include "util/simple_logger.hpp" @@ -252,7 +251,7 @@ class SharedDataFacade final : public BaseDataFacade shared_memory, storage::SharedDataLayout::NAME_CHAR_LIST); util::ShM::vector names_char_list( names_list_ptr, data_layout->num_entries[storage::SharedDataLayout::NAME_CHAR_LIST]); - m_name_table = util::make_unique>( + m_name_table = std::make_unique>( name_offsets, name_blocks, static_cast(names_char_list.size())); m_names_char_list = std::move(names_char_list); @@ -354,7 +353,7 @@ class SharedDataFacade final : public BaseDataFacade util::ShM::vector bearing_blocks( blocks_ptr, data_layout->num_entries[storage::SharedDataLayout::BEARING_BLOCKS]); - m_bearing_ranges_table = util::make_unique>( + m_bearing_ranges_table = std::make_unique>( bearing_offsets, bearing_blocks, static_cast(m_bearing_values_table.size())); auto entry_class_ptr = data_layout->GetBlockPtr( diff --git a/include/util/make_unique.hpp b/include/util/make_unique.hpp deleted file mode 100644 index 74d4e3d0e..000000000 --- a/include/util/make_unique.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef MAKE_UNIQUE_H_ -#define MAKE_UNIQUE_H_ - -#include -#include -#include - -namespace osrm -{ -namespace util -{ - -// Implement make_unique according to N3656. Taken from libcxx's implementation - -/// \brief Constructs a `new T()` with the given args and returns a -/// `unique_ptr` which owns the object. -/// -/// Example: -/// -/// auto p = make_unique(); -/// auto p = make_unique>(0, 1); -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Args &&... args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - -/// \brief Constructs a `new T[n]` with the given args and returns a -/// `unique_ptr` which owns the object. -/// -/// \param n size of the new array. -/// -/// Example: -/// -/// auto p = make_unique(2); // value-initializes the array with 0's. -template -typename std::enable_if::value && std::extent::value == 0, - std::unique_ptr>::type -make_unique(size_t n) -{ - return std::unique_ptr(new typename std::remove_extent::type[n]()); -} - -/// This function isn't used and is only here to provide better compile errors. -template -typename std::enable_if::value != 0>::type make_unique(Args &&...) = delete; -} -} - -#endif // MAKE_UNIQUE_H_ diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index add3f4c7d..6458c66f5 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -11,7 +11,6 @@ #include "extractor/raster_source.hpp" #include "util/graph_loader.hpp" #include "util/io.hpp" -#include "util/make_unique.hpp" #include "util/name_table.hpp" #include "util/range_table.hpp" #include "util/simple_logger.hpp" @@ -51,6 +50,7 @@ #include #include #include +#include namespace osrm { @@ -125,7 +125,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment) util::SimpleLogger().Write() << "Threads: " << number_of_threads; ExtractionContainers extraction_containers; - auto extractor_callbacks = util::make_unique(extraction_containers); + auto extractor_callbacks = std::make_unique(extraction_containers); const osmium::io::File input_file(config.input_path.string()); osmium::io::Reader reader(input_file); diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index 6452d775a..73b17013c 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -10,7 +10,6 @@ #include "extractor/restriction_parser.hpp" #include "util/exception.hpp" #include "util/lua_util.hpp" -#include "util/make_unique.hpp" #include "util/simple_logger.hpp" #include "util/typedefs.hpp" @@ -23,6 +22,7 @@ #include #include +#include namespace osrm { @@ -247,7 +247,7 @@ LuaScriptingContext &LuaScriptingEnvironment::GetLuaContext() auto &ref = script_contexts.local(initialized); if (!initialized) { - ref = util::make_unique(); + ref = std::make_unique(); InitContext(*ref); } luabind::set_pcall_callback(&luaErrorCallback); diff --git a/src/osrm/osrm.cpp b/src/osrm/osrm.cpp index 7b0270086..18410f839 100644 --- a/src/osrm/osrm.cpp +++ b/src/osrm/osrm.cpp @@ -7,14 +7,15 @@ #include "engine/engine.hpp" #include "engine/engine_config.hpp" #include "engine/status.hpp" -#include "util/make_unique.hpp" + +#include namespace osrm { // Pimpl idiom -OSRM::OSRM(engine::EngineConfig &config) : engine_(util::make_unique(config)) {} +OSRM::OSRM(engine::EngineConfig &config) : engine_(std::make_unique(config)) {} OSRM::~OSRM() = default; OSRM::OSRM(OSRM &&) noexcept = default; OSRM &OSRM::operator=(OSRM &&) noexcept = default; diff --git a/src/server/service_handler.cpp b/src/server/service_handler.cpp index 1bba0f6cd..adc1dae96 100644 --- a/src/server/service_handler.cpp +++ b/src/server/service_handler.cpp @@ -9,7 +9,8 @@ #include "server/api/parsed_url.hpp" #include "util/json_util.hpp" -#include "util/make_unique.hpp" + +#include namespace osrm { @@ -17,12 +18,12 @@ namespace server { ServiceHandler::ServiceHandler(osrm::EngineConfig &config) : routing_machine(config) { - service_map["route"] = util::make_unique(routing_machine); - service_map["table"] = util::make_unique(routing_machine); - service_map["nearest"] = util::make_unique(routing_machine); - service_map["trip"] = util::make_unique(routing_machine); - service_map["match"] = util::make_unique(routing_machine); - service_map["tile"] = util::make_unique(routing_machine); + service_map["route"] = std::make_unique(routing_machine); + service_map["table"] = std::make_unique(routing_machine); + service_map["nearest"] = std::make_unique(routing_machine); + service_map["trip"] = std::make_unique(routing_machine); + service_map["match"] = std::make_unique(routing_machine); + service_map["tile"] = std::make_unique(routing_machine); } engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, diff --git a/src/tools/components.cpp b/src/tools/components.cpp index f2e4cf732..e948abf8e 100644 --- a/src/tools/components.cpp +++ b/src/tools/components.cpp @@ -4,7 +4,6 @@ #include "util/exception.hpp" #include "util/fingerprint.hpp" #include "util/graph_loader.hpp" -#include "util/make_unique.hpp" #include "util/simple_logger.hpp" #include "util/static_graph.hpp" #include "util/typedefs.hpp" @@ -125,7 +124,7 @@ int main(int argc, char *argv[]) osrm::util::SimpleLogger().Write() << "Starting SCC graph traversal"; auto tarjan = - osrm::util::make_unique>(graph); + std::make_unique>(graph); tarjan->Run(); osrm::util::SimpleLogger().Write() << "identified: " << tarjan->GetNumberOfComponents() << " many components"; diff --git a/src/tools/routed.cpp b/src/tools/routed.cpp index d08730251..3160102ab 100644 --- a/src/tools/routed.cpp +++ b/src/tools/routed.cpp @@ -1,5 +1,4 @@ #include "server/server.hpp" -#include "util/make_unique.hpp" #include "util/simple_logger.hpp" #include "util/version.hpp" @@ -25,6 +24,7 @@ #include #include #include +#include #ifdef _WIN32 boost::function0 console_ctrl_function; @@ -318,7 +318,7 @@ int main(int argc, const char *argv[]) try #endif auto routing_server = server::Server::CreateServer(ip_address, ip_port, requested_thread_num); - auto service_handler = util::make_unique(config); + auto service_handler = std::make_unique(config); routing_server->RegisterServiceHandler(std::move(service_handler));