473,378 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Calling templated member of templated object

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
1 1180
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tirath | last post by:
Hi all, I have a templated class that derives from a non-templated abstract class. How do I then cast a base class pointer to a <templated> derived class pointer in a generalised fashion? ...
1
by: Rich | last post by:
Hi, I have a query regarding VC6 and its handling of templated copy constructors. Here goes: Take a look at the following code sample... template<class _Ty, size_t t_uiSize = 10 > class...
6
by: Eric Lilja | last post by:
Hello, I have a std::vector storing pointers to an abstract base class OptionBase. OptionBase is not templated but I am deriving a template class called Option from OptionBase. The class Option has...
4
by: Lionel B | last post by:
Greetings, The following code: <code> template<typename T> class A { protected:
13
by: john.constantine | last post by:
Hi I have this code: template<typename ClassType> struct S { template<typename FunctionType> void member() {}; };
6
by: Dan Huantes | last post by:
I was presented a problem today where a class had member variable that was an object of a templated class. The class wanted to instantiate the object as a private member variable and call a...
15
by: kwikius | last post by:
Hi all, I have been searching through the list of papers at: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/ I seem to remember a proposal regarding templated namespaces e.g: template...
2
by: Amadeus W. M. | last post by:
I have a bunch of templated functions: template <class Type_t> double f2(Type_t x) { return 2*x; } template <class Type_t> double f3(Type_t x) { return 3*x; }
3
by: Biswajit Jena | last post by:
Is it possible to call a member function in constructor of the same class ? how ? I have a templated member function which I want to call in the constructor of the same class. How will I do...
3
by: Rickarazzi | last post by:
This is a problem that arose while using GNU G++ 3.4.5 under Linux. The problem is: How to get a pointer value from a templated object inside a class? Normally, I would add an '&' can carry on. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.