Aracılığıyla paylaş


Derleyici Hatası C3066

Bu tür bir nesnenin bu bağımsız değişkenlerle çağrılabilmesinin birden çok yolu vardır

Açıklamalar

Derleyici, vekilleri içeren belirsiz bir işlev çağrısı algılamıştı.

Örnekler

Aşağıdaki örnek C3066 oluşturur:

// 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
}

Kopya listesi-başlatma

Visual Studio 2015'te derleyici hatalı bir şekilde copy-list-initialization işlemini normal kopya başlatma ile aynı şekilde ele alır; yalnızca aşırı yükleme çözümlemesi için oluşturucuları dönüştürmeyi düşündü. Aşağıdaki örnekte, Visual Studio 2015 MyInt(23) öğesini seçer ancak Visual Studio 2017 hatayı doğru şekilde yükseltir.

// From https://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
}