26 lines
522 B
C++
Executable file
26 lines
522 B
C++
Executable file
#include <cstddef>
|
|
|
|
#include "Types.h"
|
|
#include "Noncopyable.h"
|
|
|
|
class Executable {
|
|
MAKE_NONCOPYABLE(Executable);
|
|
MAKE_NONMOVABLE(Executable);
|
|
|
|
public:
|
|
Executable(void* code, std::size_t code_size);
|
|
~Executable();
|
|
|
|
template<typename Return>
|
|
Return run() const
|
|
{
|
|
using ExecutableFunction = Return();
|
|
auto executable_function = reinterpret_cast<ExecutableFunction*>(m_code);
|
|
|
|
return executable_function();
|
|
}
|
|
|
|
private:
|
|
void* m_code;
|
|
std::size_t m_code_size;
|
|
};
|