Implement make_unique, only require c++11 in CMakeLists (Fixes #235, Refs#167)

This commit is contained in:
saschawillems 2016-09-20 21:04:16 +02:00
parent 1908a0f190
commit b54e424d1b
2 changed files with 10 additions and 4 deletions

View file

@ -12,6 +12,14 @@
#include <mutex>
#include <condition_variable>
// make_unique is not available in C++11
// Taken from Herb Sutter's blog (https://herbsutter.com/gotw/_102/)
template<typename T, typename ...Args>
std::unique_ptr<T> make_unique(Args&& ...args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
namespace vkTools
{
class Thread
@ -95,7 +103,7 @@ namespace vkTools
threads.clear();
for (auto i = 0; i < count; i++)
{
threads.push_back(std::make_unique<Thread>());
threads.push_back(make_unique<Thread>());
}
}