class A {
int f(int x, int j) { return 2;}
decltype(f)* p;
};
daje mi błąd:decltype z funkcji członka
error: decltype cannot resolve address of overloaded function
Nie mogę zrozumieć, dlaczego ten błąd jest nawet mówiąc o przeciążonych funkcji. Podobnie myślałem, że może ja potrzebowałem użyć operatora zakresu, aby uzyskać dostęp do funkcji:
class A {
int f(int x, int j) { return 2;}
decltype(A::f)* p;
};
która wciąż daje mi błąd, ale jasny opis:
error: invalid use of non-static member function 'int A::f(int, int)'
Dlaczego jest to, że nie jestem można używać decltype, aby znaleźć typ funkcji członka? Alternatywnie ustawienie funkcji składowej na static
powoduje usunięcie błędu w obu przypadkach.
jakiej wersji kompilatora i kompilatora używasz? –
@RichardChambers g ++ 4.8.1 – Silversonic