From c0265ba0e42e243919f2cc7d352411e32423ca16 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Thu, 25 Dec 2014 17:33:34 +0100 Subject: [PATCH] refs #320 Move own implementation of std::make_unique into BlackMisc --- src/blackcore/voice_vatlib.cpp | 1 + src/blackmisc/blackmiscfreefunctions.h | 9 +++++++++ src/xbus/menus.cpp | 11 ++--------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/blackcore/voice_vatlib.cpp b/src/blackcore/voice_vatlib.cpp index 9bec3d5f3..3554838f7 100644 --- a/src/blackcore/voice_vatlib.cpp +++ b/src/blackcore/voice_vatlib.cpp @@ -6,6 +6,7 @@ #include "voice_vatlib.h" #include "voice_channel_vatlib.h" #include "blackmisc/logmessage.h" +#include "blackmisc/blackmiscfreefunctions.h" #include #include #include diff --git a/src/blackmisc/blackmiscfreefunctions.h b/src/blackmisc/blackmiscfreefunctions.h index d7fa1de2f..14406cecb 100644 --- a/src/blackmisc/blackmiscfreefunctions.h +++ b/src/blackmisc/blackmiscfreefunctions.h @@ -17,6 +17,8 @@ #include #include +#include + /*! * Workaround, to call initResource from namespace. Used in BlackMisc::initResources(). * Q_INIT_RESOURCE adds resource, here the translation files. @@ -162,6 +164,13 @@ namespace BlackMisc //! Get local host name env.variable const QString &localHostNameEnvVariable(); + //! Own implementation of std::make_unique, a C++14 feature not provided by GCC in C++11 mode + template + std::unique_ptr make_unique(Args&&... args) + { + return std::unique_ptr(new T(std::forward(args)...)); + } + } // BlackMisc #endif // guard diff --git a/src/xbus/menus.cpp b/src/xbus/menus.cpp index aea46a4bf..c5ca9f1bb 100644 --- a/src/xbus/menus.cpp +++ b/src/xbus/menus.cpp @@ -4,20 +4,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "menus.h" +#include "blackmisc/blackmiscfreefunctions.h" #include #include #include namespace XBus { - - // Own implementation of std::make_unique, a C++14 feature not provided by GCC in C++11 mode - template - std::unique_ptr make_unique(Args&&... args) - { - return std::unique_ptr(new T(std::forward(args)...)); - } - template void *voidptr_cast(T i) // "safe" cast from integer to void* { static_assert(std::is_integral::value, "voidptr_cast expects an integer"); @@ -77,7 +70,7 @@ namespace XBus CMenu CMenu::subMenu(std::string name) { assert(! name.empty()); - auto items = make_unique(); + auto items = BlackMisc::make_unique(); auto itemsVoidPtr = static_cast(&*items); return { XPLMCreateMenu(name.c_str(), m_data->id, XPLMAppendMenuItem(m_data->id, name.c_str(), nullptr, false), handler, itemsVoidPtr), false, std::move(items) }; }