address of overloaded function with no contextual type information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux