是否有一个标准类型来取消类型标记?它可能会这样实现:
template<class T>
using untokenize = T;
Run Code Online (Sandbox Code Playgroud)
这样我可以使用重载运算符执行以下转换:
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
Run Code Online (Sandbox Code Playgroud)
或者是否有另一种更标准的方法来实现我的目标,即避免使用 c 风格转换而支持函数风格转换?