473,396 Members | 1,748 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,396 software developers and data experts.

it looks good but doesn't compile :(

i have a problem with the following code, it does not compile and i do
not understand why.

the interesting thing is that if function call_f is renamed to f the
compiler is happy.

any kind soul has any clue?

thanks
dom
$ g++ -c broken.cpp
broken.cpp: In function `T* call_f(A&)':
broken.cpp:15: error: syntax error before `>' token
$

----------- CUT HERE -----------
// broken.cpp

struct A
{
template<typename T>
T* f()
{
return 0;
}
};

template<typename T>
T* call_f(A& a)
{
return a.f<T>();
}
----------- CUT HERE -----------
-----[ Domenico Andreoli, aka cavok
--[ http://filibusta.crema.unimi.it/~cavok/gpgkey.asc
---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50
Jul 19 '05 #1
1 1308
"Domenico Andreoli" <ca***@freemail.it> wrote...
i have a problem with the following code, it does not compile and i do
not understand why.

the interesting thing is that if function call_f is renamed to f the
compiler is happy.

any kind soul has any clue?

thanks
dom
$ g++ -c broken.cpp
broken.cpp: In function `T* call_f(A&)':
broken.cpp:15: error: syntax error before `>' token
$

----------- CUT HERE -----------
// broken.cpp

struct A
{
template<typename T>
T* f()
{
return 0;
}
};

template<typename T>
T* call_f(A& a)
{
return a.f<T>();
Change this to

return a.template f<T>();
}
----------- CUT HERE -----------


I am not sure why gcc needs that 'template' there. According to
3.4.5, there should be no need for that.

Victor
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Paul Rubin | last post by:
I've been approached about writing a Windows app which will need a really professional looking GUI. Forget TKinter, this has to actually look good (real artists will be available to get the visual...
30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
77
by: Hunn E. Balsiche | last post by:
in term of its OO features, syntax consistencies, ease of use, and their development progress. I have not use python but heard about it quite often; and ruby, is it mature enough to be use for...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
8
by: G Patel | last post by:
Can people please comment on the layout/style of my problem? The major issue I had was the layout. I ended up having to put a relatively large switch statement, inside an if statement, which is...
3
by: ashkaan57 | last post by:
Hi, I have a page that looks crooked in Firefox but displays normally in IE. http://www.legalpersian.com The page was designed using Visual Web Developer 2005 (part of MS Vsual Studio 2005...
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
244
by: Ajinkya | last post by:
Can anyone suggest me a good compiler for(c/cpp) for windows? I tried dev cpp but its debugging facility is very poor.
159
by: bernard | last post by:
howdy! please recommend a good c compiler. - should be small - should be fast - should come with a good ide - should be inexpensive i am using windows os.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.