use proper c++11 std::forward

This commit is contained in:
Kelvin Sherlock 2014-11-21 09:50:56 -05:00
parent 6f50f9de03
commit ff52cae4e9

View File

@ -2,6 +2,7 @@
#define __StackFrame_h__
#include <cstdint>
#include <utility>
//
@ -22,9 +23,9 @@ void ToolReturn(uint32_t sp, uint32_t value)
// pre-define these templates to prevent instantiation errors.
template<int Bytes, int Offset, typename... Args>
uint32_t StackFrame__(uint32_t sp, uint32_t &x, Args&... args);
uint32_t StackFrame__(uint32_t sp, uint32_t &x, Args&&... args);
template<int Bytes, int Offset, typename... Args>
uint32_t StackFrame__(uint32_t sp, uint16_t &x, Args&... args);
uint32_t StackFrame__(uint32_t sp, uint16_t &x, Args&&... args);
template<int Bytes, int Offset>
uint32_t StackFrame__(uint32_t sp);
@ -39,27 +40,27 @@ uint32_t StackFrame__(uint32_t sp)
}
template<int Bytes, int Offset, typename... Args>
uint32_t StackFrame__(uint32_t sp, uint32_t &x, Args&... args)
uint32_t StackFrame__(uint32_t sp, uint32_t &x, Args&&... args)
{
x = memoryReadLong(sp + Offset - 4);
return StackFrame__<Bytes, Offset - 4>(sp, args...);
return StackFrame__<Bytes, Offset - 4>(sp, std::forward<Args>(args)...);
}
template<int Bytes, int Offset, typename... Args>
uint32_t StackFrame__(uint32_t sp, uint16_t &x, Args&... args)
uint32_t StackFrame__(uint32_t sp, uint16_t &x, Args&&... args)
{
x = memoryReadWord(sp + Offset - 2);
return StackFrame__<Bytes, Offset - 2>(sp, args...);
return StackFrame__<Bytes, Offset - 2>(sp, std::forward<Args>(args)...);
}
template<int Bytes, typename... Args>
uint32_t StackFrame(Args&... args)
uint32_t StackFrame(Args&&... args)
{
uint32_t sp = cpuGetAReg(7);
return StackFrame__<Bytes, Bytes>(sp, args...);
return StackFrame__<Bytes, Bytes>(sp, std::forward<Args>(args)...);
}