Pointer to a template function

K

Kufa

Hi,

I have nailed down a piece of code that is obviously wrong, but cannot
find what i should i do to make it ansi compliant, neither where in
the reference i should look.
Basically i m trying to get a pointer on a static function of a
template class:

struct A
{
template< class Type1 > struct B
{
template< bool B1, bool B2, bool B3 > static void func( int, int )
{}
};

template< class Type2 > void test();
};

typedef void (*FuncType)(int,int);

template< class Type2 > void A::test()
{
FuncType ptr = &B<Type2>::func<true,true,true>;
ptr(0,0);
}

I know that specializing func outside B wouldnt be correct, but
getting a pointer on it should be allright, right?

Any help is welcome,
Thanks,

/david
 
M

Marco Manfredini

Kufa wrote:
[...]
typedef void (*FuncType)(int,int);

template< class Type2 > void A::test()
{
FuncType ptr = &B<Type2>::func<true,true,true>;
try this:
FuncType ptr = &B<Type2>::template func<true,true,true>;
 
K

Kira Yamato

Kufa wrote:
[...]
typedef void (*FuncType)(int,int);

template< class Type2 > void A::test()
{
FuncType ptr = &B<Type2>::func<true,true,true>;
try this:
FuncType ptr = &B<Type2>::template func<true,true,true>;

o_O

C++ truly is a complicated language. It's almost like physics: The
more I learn about it, the more I feel I don't know it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top