içinde yakalanması için üye işlevine muğlak çağrı Bir yakalanan bir this
için bir lambda içinde üye işlevini çağırmaya çalışırken bir sorunla karşılaştım. İşlevin bir const ve const olmayan sürümü vardır ve bir tür üzerinde templated edilir.Bir lambda
struct TEST
{
template <typename T>
void test() {}
template <typename T>
void test() const {}
TEST()
{
[this]()
{
test<void>();
}();
}
};
Mesajlar:
Aşağıdaki kod hata gösterir http://rextester.com/MLU2098
source_file.cpp(13): error C2668: 'TEST::test': ambiguous call to overloaded function
source_file.cpp(7): note: could be 'void TEST::test<void>(void) const'
source_file.cpp(4): note: or 'void TEST::test<void>(void)'
source_file.cpp(13): note: while trying to match the argument list '()'
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64
bu davranış doğru ve Microsoft derleyici ile sadece bir sorun olup olmadığından emin değildi, bu yüzden test derleyici kaşifinde gcc ve clang ile kod ve her ikisi de bir hata olmadan kodu derlediler.
Burada hangi derleyici doğru davranışı gösteriyor?
[Burada MSVC ile üreme var] (http://rextester.com/MLU2098) – AndyG