public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* address of overloaded function with no contextual type information
@ 2010-08-11 21:09 Adam Burr
  2010-08-11 21:45 ` Tiago Maluta
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Burr @ 2010-08-11 21:09 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-11 22:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 21:09 address of overloaded function with no contextual type information Adam Burr
2010-08-11 21:45 ` Tiago Maluta
2010-08-11 21:50   ` Adam Burr
2010-08-11 21:57     ` Tiago Maluta
2010-08-11 22:08       ` Adam Burr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).