By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

Calling templated member of templated object

P: n/a
template< typename T >
void f( T & t )
{
t.g<int>();
}

MSVC 2005 compiles this without problems (yes, even when it's
instantiated). g++ gives errors. Comeau compiles in "relaxed" mode,
but in "strict" mode gives

"ComeauTest.c", line 4: error: type name is not allowed
t.g<int>();
^

"ComeauTest.c", line 4: error: expected an expression
t.g<int>();
^

Clearly, it's assuming the < is a less-than operator. What is the
"strict" way of doing this?
--
David

Jun 22 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jun 22, 10:03 am, d...@sunlightd.com wrote:
template< typename T >
void f( T & t )
{
t.g<int>();

}
try

void f( T & t )
{
t.template g<int>();

}

>
MSVC 2005 compiles this without problems (yes, even when it's
instantiated). g++ gives errors. Comeau compiles in "relaxed" mode,
but in "strict" mode gives

"ComeauTest.c", line 4: error: type name is not allowed
t.g<int>();
^

"ComeauTest.c", line 4: error: expected an expression
t.g<int>();
^

Clearly, it's assuming the < is a less-than operator. What is the
"strict" way of doing this?
--
David

Jun 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.