template< class T >
struct tTest
{
template< class T2 >
static T2 func( const T& ac_tType )
{
//actual code does stuff to convert T->T2 here
return T2();
}
};
template< class T >
struct tUsesTest
{
typedef tTest< T > mt_Test;
void func()
{
T test;
int nConverted = mt_Test::func<unsigned int>( test );
}
};
int main(int argc, char* argv[])
{
tUsesTest< int > test;
test.func();
return 0;
}
template< class T >
struct tTest
{
template< class T2 >
static T2 func( const T& ac_tType )
{
//actual code does stuff to convert T->T2 here
return T2();
}
};
template< class T >
struct tUsesTest
{
typedef tTest< T > mt_Test;
void func()
{
T test;
int nConverted = mt_Test::func<unsigned int>( test );
}
};
int main(int argc, char* argv[])
{
tUsesTest< int > test;
test.func();
return 0;
}
To copy to clipboard, switch view to plain text mode
You had a couple of errors back there. For example you did not specify the T2 type for func in tUsesTest. So the compiler could not deduce the type out of thin air
.
And in tTest, func had a weird syntax. It did resembled a bit with pointer to function syntax, but it wasn't correct.
Try the code I posted. Should work with gcc too.
Bookmarks