mardi 1 décembre 2015

Pointer to function members: what does `R(*C::*)(Args...)` mean?

Consider the following code:

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> {};

I have absolutely no idea of what (*C::*), (**C::*), (C::**) and (C::***) mean. I would like an example of a test<decltype(f)> whose value would be equal to 2, 3, 4 and 5. Plus, in that case, how is the syntax for f that would call the member function?

Aucun commentaire:

Enregistrer un commentaire