I'm having difficulty passing a pointer to the member function Outer<T>::foo
to the constructor of the nested class Outer
as shown below (see also ideone).
template<typename T1>
struct Outer
{
void foo()
{
}
Outer() : inner( &Outer::foo ) // ERROR: compiles without &Outer::foo and Inner( F f ), below
{
}
template<typename T2, void (T2::*F)()>
struct Inner
{
Inner( F f ) // ERROR
{
}
};
Inner<Outer,&Outer::foo> inner;
};
int main()
{
Outer<int> outer;
}
What am I doing wrong? I've begun to wonder if this is at all possible.
F
is not a type, it's a function pointer. Why are you passing a parameter if you already know what the object is? – CubitOuter<T1>::Inner
is a nested template type. – Kenner