컴파일러 오류 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
}
Copy-list-initialization
Visual Studio 2015에서 컴파일러는 일반 copy-initialization과 같은 방식으로 copy-list-initialization을 잘못 처리했고 오버로드 확인을 위해 생성자 변환만 고려했습니다. 다음 예제에서 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
}