From: Adam Burr <adamb@blueskystudios.com>
To: gcc-help@gcc.gnu.org
Subject: address of overloaded function with no contextual type information
Date: Wed, 11 Aug 2010 21:09:00 -0000 [thread overview]
Message-ID: <4C631170.8040101@blueskystudios.com> (raw)
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
next reply other threads:[~2010-08-11 21:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-11 21:09 Adam Burr [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C631170.8040101@blueskystudios.com \
--to=adamb@blueskystudios.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).