奇怪的铸造问题
Odd casting issue
奇怪的转换问题
为了节省时间,我直接跳到问题
在我的一个 return 函数中,我通过如下 using 语句设置了一个引用:
示例:using T = int( __thiscall* )( void* );
现在,在这个语句中我有一个 return,它将在 return 中收集来自 return 引用类型指针的偏移量:
示例:return ( *reinterpret_cast< T** >( this ) )[0X0]( this );
当我利用我的 using 语句使用引用时,操作 return 成功并且我的函数将正常工作。但是,当不使用该语句并评估引用本机时,我的编译器会向我返回一些标记,说明它无法处理。
我正在尝试做的事情的例子:return ( *reinterpret_cast< int( __thiscall* )( void* )** >( this ) )[0X0]( this );
我是否遗漏了什么,或者这是不可能的?
作为一个纯粹的语法问题,没有深入研究为什么你这样做,指针到指针到指针到函数的语法是在通常只放置一个的地方增加 *
限定符的数量:
return ( *reinterpret_cast< int( __thiscall*** )( void* ) >( this ) )[0X0]( this );
^^^
而不是仅仅在最后添加它们——这适用于类型别名,但不适用于多级函数指针类型。
奇怪的转换问题
为了节省时间,我直接跳到问题
在我的一个 return 函数中,我通过如下 using 语句设置了一个引用:
示例:using T = int( __thiscall* )( void* );
现在,在这个语句中我有一个 return,它将在 return 中收集来自 return 引用类型指针的偏移量:
示例:return ( *reinterpret_cast< T** >( this ) )[0X0]( this );
当我利用我的 using 语句使用引用时,操作 return 成功并且我的函数将正常工作。但是,当不使用该语句并评估引用本机时,我的编译器会向我返回一些标记,说明它无法处理。
我正在尝试做的事情的例子:return ( *reinterpret_cast< int( __thiscall* )( void* )** >( this ) )[0X0]( this );
我是否遗漏了什么,或者这是不可能的?
作为一个纯粹的语法问题,没有深入研究为什么你这样做,指针到指针到指针到函数的语法是在通常只放置一个的地方增加 *
限定符的数量:
return ( *reinterpret_cast< int( __thiscall*** )( void* ) >( this ) )[0X0]( this );
^^^
而不是仅仅在最后添加它们——这适用于类型别名,但不适用于多级函数指针类型。