Does anyone know what I'm doing wrong here?
#include <iostream>
template< typename T >
struct thingA
{
template< int I >
static int doA () {return I;}
struct thingB
{
void doB ()
{
// this line does not compile:
int (*doAPtr) () = &thingA< T >::doA< 2 >;
std::cerr << (*doAPtr) () << std::endl;
}
};
};
int main (int, char **)
{
thingA< int >::thingB a;
a.doB ();
}
This is a contrived example but in the "real world" I do need to get a
pointer to a static template function inside a template class like this.
Here is the gcc error:
main.cc: In member function 'void thingA<T>::thingB::doB()':
main.cc:14: error: expected primary-expression before ';' token
main.cc: In member function 'void thingA<T>::thingB::doB() [with T = int]':
main.cc:23: instantiated from here
main.cc:14: error: address of overloaded function with no contextual
type information
Any help is appreciated.
Thanks,
Adam Burr
Blue Sky Studios