Based on my other question .
Consider the following code
template<typename T, int N> struct A { typedef T value_type;
Look, I can use value_type and size as a template parameter.
typedef A<int, 2> A1; typedef A<A1::value_type, A1::size + 3> A2;
Now I want to do the same with a member pointer:
struct Foo { int m; int r; }; template<int Foo::*Mem> struct B { static int Foo::* const mp; }; template<int Foo::*Mem> int Foo::* const B<Mem>::mp = Mem;
But I get an error.
typedef B<&Foo::m> B1; typedef B<B1::mp> B2;
How to make the last line work? Or how to get a simulation result?
Note. I know this is not working. No references to the C ++ standard are required. I need a workaround.
c ++ templates pointer-to-member
Alexey Malistov
source share