奇怪的问题

问题描述 投票:0回答:1

奇数投放问题

为了节省时间,我将直接跳过该问题。

虽然在我的一个返回函数中,我通过使用如下的using语句建立了引用:

示例:using T = int( __thiscall* )( void* );

现在,在此语句中,我有一个返回值,该返回值将从返回的引用类型指针中收集一个偏移量:

示例:return ( *reinterpret_cast< T** >( this ) )[0X0]( this );

当我通过我的using语句使用引用时,该操作将成功返回,并且我的函数将正常工作。但是,当不使用该语句并评估本机引用时,我的编译器将向我抛出一些令牌,表明无法对其进行处理。

我尝试执行的操作示例:return ( *reinterpret_cast< int( __thiscall* )( void* )** >( this ) )[0X0]( this );

我是否缺少某些东西,或者这是不可能的吗?

c++ pointers casting reinterpret-cast
1个回答
0
投票

纯粹是一个语法问题,而无需深入研究why,执行指针对指针对指针对函数的语法是增加*限定词的数量,其中您通常只放一个:

return ( *reinterpret_cast< int( __thiscall*** )( void* ) >( this ) )[0X0]( this );
                                           ^^^

而不是仅在最后添加内容-它适用于类型别名,但不适用于多级指针到函数类型。

© www.soinside.com 2019 - 2024. All rights reserved.