编译器错误 C3066
可通过多种方式使用这些参数调用此类型的对象
编译器检测到涉及代理项的不明确的函数调用。
以下示例生成 C3066:
// C3066.cpp
template <class T, class U> void func(T*, U*){}
typedef void (*PF)(const int*, const char*);
typedef void (*PF1)(const int*, volatile char*);
struct A {
operator PF() const {
return func;
}
operator PF1() {
return func;
}
operator PF1() const {
return func;
}
};
int main() {
A a;
int i;
char c;
a(&i, &c); // C3066
a(&i, (const char *) &c); // OK
}
复制列表初始化
在 Visual Studio 2015 中,编译器以与常规复制初始化相同的方式错误地处理复制列表初始化;它只考虑将转换构造函数用于重载决策。 在以下示例中,Visual Studio 2015 选择 MyInt(23),但 Visual Studio 2017 正确引发错误。
// From http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1228
struct MyList {
explicit MyStore(int initialCapacity);
};
struct MyInt {
MyInt(int i);
};
struct Printer {
void operator()(MyStore const& s);
void operator()(MyInt const& i);
};
void f() {
Printer p;
p({ 23 }); // C3066: there are multiple ways that an object of this type can be called with these arguments
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈