From c96849f431bb4152a4258d2480bef8cd272e0c6e Mon Sep 17 00:00:00 2001 From: tycho Date: Fri, 15 May 2015 13:57:27 +0100 Subject: Move make_unique into a namespace to avoid ADL issues this prevents VS finding std::make_unique for constructors that take types from std --- src/Globals.h | 10 +++++++--- src/Root.cpp | 4 ++-- src/World.cpp | 10 +++++----- src/main.cpp | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Globals.h b/src/Globals.h index cee2094bc..27d944fcc 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -433,10 +433,14 @@ typename std::enable_if::value, C>::type CeilC(T a_Value) //temporary replacement for std::make_unique until we get c++14 -template -std::unique_ptr make_unique(Args&&... args) + +namespace cpp14 { - return std::unique_ptr(new T(std::forward(args)...)); + template + std::unique_ptr make_unique(Args&&... args) + { + return std::unique_ptr(new T(std::forward(args)...)); + } } // a tick is 50 ms diff --git a/src/Root.cpp b/src/Root.cpp index de53e0cd8..c3c880e73 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -133,7 +133,7 @@ void cRoot::Start(std::unique_ptr overridesRepo) LOG("Reading server config..."); - auto IniFile = make_unique(); + auto IniFile = cpp14::make_unique(); if (!IniFile->ReadFile("settings.ini")) { LOGWARN("Regenerating settings.ini, all settings will be reset"); @@ -141,7 +141,7 @@ void cRoot::Start(std::unique_ptr overridesRepo) IniFile->AddHeaderComment(" Most of the settings here can be configured using the webadmin interface, if enabled in webadmin.ini"); IniFile->AddHeaderComment(" See: http://wiki.mc-server.org/doku.php?id=configure:settings.ini for further configuration help"); } - auto settingsRepo = make_unique(std::move(IniFile), std::move(overridesRepo)); + auto settingsRepo = cpp14::make_unique(std::move(IniFile), std::move(overridesRepo)); LOG("Starting server..."); m_MojangAPI = new cMojangAPI; diff --git a/src/World.cpp b/src/World.cpp index c0a79b9d0..eb8835467 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -621,18 +621,18 @@ void cWorld::Start(void) InitialiseAndLoadMobSpawningValues(IniFile); SetTimeOfDay(IniFile.GetValueSetI("General", "TimeInTicks", GetTimeOfDay())); - m_ChunkMap = make_unique(this); + m_ChunkMap = cpp14::make_unique(this); // preallocate some memory for ticking blocks so we don't need to allocate that often m_BlockTickQueue.reserve(1000); m_BlockTickQueueCopy.reserve(1000); // Simulators: - m_SimulatorManager = make_unique(*this); + m_SimulatorManager = cpp14::make_unique(*this); m_WaterSimulator = InitializeFluidSimulator(IniFile, "Water", E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER); m_LavaSimulator = InitializeFluidSimulator(IniFile, "Lava", E_BLOCK_LAVA, E_BLOCK_STATIONARY_LAVA); - m_SandSimulator = make_unique(*this, IniFile); - m_FireSimulator = make_unique(*this, IniFile); + m_SandSimulator = cpp14::make_unique(*this, IniFile); + m_FireSimulator = cpp14::make_unique(*this, IniFile); m_RedstoneSimulator = InitializeRedstoneSimulator(IniFile); // Water, Lava and Redstone simulators get registered in their initialize function. @@ -2680,7 +2680,7 @@ void cWorld::UnloadUnusedChunks(void) void cWorld::QueueUnloadUnusedChunks(void) { - QueueTask(make_unique()); + QueueTask(cpp14::make_unique()); } diff --git a/src/main.cpp b/src/main.cpp index d37ff0b32..9f57ad6bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -376,7 +376,7 @@ std::unique_ptr parseArguments(int argc, char **argv) int slots = slotsArg.getValue(); - auto repo = make_unique(); + auto repo = cpp14::make_unique(); repo->SetValueI("Server", "MaxPlayers", slots); -- cgit v1.2.3