“使用X = int(&)()”做什么? [重复]

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

当我浏览Quora时,我看到了以下类型的代码。

#include <iostream>
int f() 
{ 
   return 1; 
}

int main()
{
    int (&var1)() = f;
    using X = int(&)();
    int i = reinterpret_cast<X>(var1)();
    std::cout << " i = " << i << '\n';
}

那么,using X = int(&)()做什么?

c++ c++11
1个回答
2
投票

该声明使X成为等号右侧类型的别名。

然后在下一个语句中使用该别名。

this reference page on the using keyword

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