我不知道为什么这不起作用.以下Function内容由placement new创建.提供了一个函数,用于检查是否应该销毁它,如果是,则手动调用其析构函数.
这是测试用例,似乎从不调用析构函数:
/* Represents a function at runtime */
class Function {
public:
/* Creates an invalid function */
Function():codeptr(0) { }
/* Creates a function with the given code pointer */
Function(void *codeptr):codeptr(codeptr) { }
/* Frees the function machine code */
~Function() {
if(*this) {
/* <- I explicitly put a debug output here! */
destroyLLVMCode(codeptr);
}
}
public:
/* Returns true if the function is valid
* (if the code pointer is non-null)
*/ …Run Code Online (Sandbox Code Playgroud)