Fixed variadic arguments not being moved
Former-commit-id: 1130a384e982a792d04dc9490a12797cb73bc349
This commit is contained in:
parent
adb268fec8
commit
655be2864f
|
|
@ -32,7 +32,7 @@ struct NzFunctorWithoutArgs : NzFunctor
|
|||
template<typename F, typename... Args>
|
||||
struct NzFunctorWithArgs : NzFunctor
|
||||
{
|
||||
NzFunctorWithArgs(F func, Args&... args);
|
||||
NzFunctorWithArgs(F func, Args&&... args);
|
||||
|
||||
void Run();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <utility>
|
||||
|
||||
template<typename F>
|
||||
NzFunctorWithoutArgs<F>::NzFunctorWithoutArgs(F func) :
|
||||
m_func(func)
|
||||
|
|
@ -15,9 +17,9 @@ void NzFunctorWithoutArgs<F>::Run()
|
|||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
NzFunctorWithArgs<F, Args...>::NzFunctorWithArgs(F func, Args&... args) :
|
||||
NzFunctorWithArgs<F, Args...>::NzFunctorWithArgs(F func, Args&&... args) :
|
||||
m_func(func),
|
||||
m_args(args...)
|
||||
m_args(std::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ void NzOperatorDelete(void* ptr);
|
|||
void* NzOperatorNew(std::size_t size);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* NzPlacementNew(void* ptr, Args... args);
|
||||
T* NzPlacementNew(void* ptr, Args&&... args);
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <new>
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline void NzOperatorDelete(void* ptr)
|
||||
|
|
@ -32,7 +33,7 @@ inline void* NzOperatorNew(std::size_t size)
|
|||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* NzPlacementNew(void* ptr, Args... args)
|
||||
T* NzPlacementNew(void* ptr, Args&&... args)
|
||||
{
|
||||
return new (ptr) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class NAZARA_API NzTaskScheduler
|
|||
~NzTaskScheduler() = delete;
|
||||
|
||||
template<typename F> static void AddTask(F function);
|
||||
template<typename F, typename... Args> static void AddTask(F function, Args... args);
|
||||
template<typename F, typename... Args> static void AddTask(F function, Args&&... args);
|
||||
template<typename C> static void AddTask(void (C::*function)(), C* object);
|
||||
static unsigned int GetWorkerCount();
|
||||
static bool Initialize();
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ void NzTaskScheduler::AddTask(F function)
|
|||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
void NzTaskScheduler::AddTask(F function, Args... args)
|
||||
void NzTaskScheduler::AddTask(F function, Args&&... args)
|
||||
{
|
||||
AddTaskFunctor(new NzFunctorWithArgs<F, Args...>(function, args...));
|
||||
AddTaskFunctor(new NzFunctorWithArgs<F, Args...>(function, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class NAZARA_API NzThread : NzNonCopyable
|
|||
|
||||
NzThread();
|
||||
template<typename F> NzThread(F function);
|
||||
template<typename F, typename... Args> NzThread(F function, Args... args);
|
||||
template<typename F, typename... Args> NzThread(F function, Args&&... args);
|
||||
template<typename C> NzThread(void (C::*function)(), C* object);
|
||||
NzThread(NzThread&& other);
|
||||
~NzThread();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename F>
|
||||
|
|
@ -11,9 +12,9 @@ NzThread::NzThread(F function)
|
|||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
NzThread::NzThread(F function, Args... args)
|
||||
NzThread::NzThread(F function, Args&&... args)
|
||||
{
|
||||
CreateImpl(new NzFunctorWithArgs<F, Args...>(function, args...));
|
||||
CreateImpl(new NzFunctorWithArgs<F, Args...>(function, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
|
|
|||
Loading…
Reference in New Issue