Betrachten Sie den folgenden Code ein:Zeiger auf Funktionsmember: Was bedeutet `R (* C :: *) (Args ...) '?
template <class>
struct test: std::integral_constant<int, 0> {};
template<class R, class C, class... Args>
struct test<R(C::*)(Args...)>: std::integral_constant<int, 1> {};
template<class R, class C, class... Args>
struct test<R(*C::*)(Args...)>: std::integral_constant<int, 2> {};
template<class R, class C, class... Args>
struct test<R(**C::*)(Args...)>: std::integral_constant<int, 3> {};
template<class R, class C, class... Args>
struct test<R(C::**)(Args...)>: std::integral_constant<int, 4> {};
template<class R, class C, class... Args>
struct test<R(C::***)(Args...)>: std::integral_constant<int, 5> {};
Ich habe absolut keine Ahnung, was (*C::*)
, (**C::*)
, (C::**)
und (C::***)
bedeuten. Ich möchte ein Beispiel für eine test<decltype(f)>
, deren value
würde gleich 2
, 3
, 4
und 5
sein. Plus, in diesem Fall, wie lautet die Syntax für f
, die die Member-Funktion aufrufen würde?
Danke! Könnten Sie ein Beispiel geben, wenn 's' einen Funktionsmember' int f (int x) {return x;} 'hat und' testN' sich darauf bezieht, wie lautet die Syntax zum Ausführen von 'testN' auf einer Variablen? – Vincent
@Vincent, ich kam dazu. Eine Sekunde. – chris