ich habe gerade ein seltsames Problem, in dem ich eine template-Methode aus einem Lambda heraus aufrufen will und dazu this capture. Und nur VisualStudio 2017 liefert mir "mehrdeutiger Aufruf", GCC und CLANG kompilieren das sauber. Scheint also ein Compilerbug zu sein, aber wessen Fehler?
Code: Alles auswählen
#include <tuple>
class A {
public:
std::tuple<int, float, double> t;
template <typename T> T& Get() { return std::get<T>( t); }
template <typename T> const T& Get() const { return std::get<T>( t); }
void foo() {
[this]() { Get<int>(); }();
}
};
Code: Alles auswählen
<source>(11): error C2668: 'A::Get': ambiguous call to overloaded function
<source>(8): note: could be 'const T &A::Get<int>(void) const'
with [ T=int ]
<source>(7): note: or 'T &A::Get<int>(void)'
with [ T=int ]
<source>(11): note: while trying to match the argument list '()'