编译器警告(等级 1)C4927
转换非法;隐式应用了多个用户定义的转换
多个用户定义的转换隐式应用于某一个值 -- 编译器未找到显式转换,但确实找到了它使用的转换。
下面的示例生成 C4927:
// C4927.cpp
// compile with: /W1
struct B
{
operator int ()
{
return 0;
}
};
struct A
{
A(int i)
{
}
/*
// uncomment this constructor to resolve
A(B b)
{
}
*/
};
A f1( B& b)
{
return A(b);
}
B& f2( B& b)
{
return b;
}
A f()
{
B b;
return A(b); // ok
return f1(b); // ok
return b; // C4927
return B(b); // C4927
return f2(b); // C4927
}
int main()
{
B b;
A a = b;
A a2(b);
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈