是否有标准类型来取消标记类型?它可能会这样实现:
template<class T>
using untokenize = T;
这样我就可以使用重载运算符执行以下转换:
struct x {
int y;
operator int&() {
return y;
}
};
x a;
// int&(a); // doesn't work
// (int&)(a); // not the same thing
untokenize<int&>(a); // works great
或者是否有另一种更标准的方法来实现我的目标,即避免使用 c 风格的强制转换,转而使用函数风格的强制转换?
最佳答案
static_cast<T>
做你要求的。
关于c++ - 是否有标准的 Untokenize 模板化类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70408591/