Initial commit
This commit is contained in:
commit
ef40bd03c5
14 changed files with 276 additions and 0 deletions
26
include/Executable.h
Executable file
26
include/Executable.h
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#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;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue