473,396 Members | 2,004 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.

VC7.1: Parser bug with overloaded function templates

Hi,

VC7.1 compiles the following, however, CW9, GCC 3.4.0, and
Comeau reject it:

#include <iostream>
#include <typeinfo>

class Test1 {};
class Test2 {};
class Test3 {};

template< typename T >
struct Cont { T t; };

template< typename T >
class TT { public: TT(T) {} };

struct X {

template< template<typename> class TT, typename T >
static void f(const T& t)
{
std::cout << '\t' << typeid(t).name() << std::endl;
}

template< template<typename> class TT >
static void f(const Test3& t)
{
std::cout << '\t' << typeid(t).name() << std::endl;
}

template< template<typename> class TT, typename T >
static void f(const Cont<T>& c)
{
f<TT>( c.t ); // <== error here
}

};

int main()
{
Cont<Test1> c1;
Cont<Test2> c2;
Cont<Test3> c3;

X::f< TT, Test1 >(c1);
X::f< TT, Test2 >(c2);
X::f< TT, Test3 >(c3);

return 0;
}

I had to learn that the call marked with "error here"
is ambigous.

TIA,

Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers


Nov 17 '05 #1
2 881
Hendrik Schober wrote:
Hi,

VC7.1 compiles the following, however, CW9, GCC 3.4.0, and
Comeau reject it:


Whidbey accepts it as well. I'll submit it as a bug report if no one beats
me to it.

-cd
Nov 17 '05 #2
Carl Daniel [VC++ MVP] <cp*****************************@mvps.org.nospam > wrote:
Hendrik Schober wrote:
Hi,

VC7.1 compiles the following, however, CW9, GCC 3.4.0, and
Comeau reject it:
Whidbey accepts it as well. I'll submit it as a bug report if no one beats
me to it.


Thanks, Carl!
-cd

Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
Nov 17 '05 #3

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

Similar topics

0
by: adanpradan | last post by:
Hello, we have created two files sample.xml and sample.xsl The code in sample.xml <?xml version="1.0"?> <department> <dept-name>
3
by: CoolPint | last post by:
In the code below, shouldn't the function call minimum(a,a); result in compilation error? I read in Lippman's C++ Primer 3rd Edition on page 521, the call should be ambiguous. But on g++...
6
by: PengYu.UT | last post by:
Hi, I run into error with the following program. Would you please help me? Best wishes, Peng struct tag1{}; struct tag2{};
44
by: bahadir.balban | last post by:
Hi, What's the best way to implement an overloaded function in C? For instance if you want to have generic print function for various structures, my implementation would be with a case...
10
by: andrew browning | last post by:
i have overlaoded all of my arithmetic operators but all are functioning as multiplication. below is a sample of the addition operator: Rational operator + (const Rational& r1, const Rational&...
4
by: dalu.gelu | last post by:
can u let me know if two functions having same name foo(), one is atemplate function and otherone being ordinary function. if i invoked the function from main(), which function is to called & why....
2
by: desktop | last post by:
If a function should work with different types you normally overload it: void myfun(int a){ // do int stuff } void myfun(std::string str){ // do string stuff }
5
by: Lars Hillebrand | last post by:
Hello, i discovered a weird behaviour if i use templates together with virtual inheritance and method over. I managed to reproduce my problem with a small example: // *********** <code...
29
by: Dexter | last post by:
This Java based utility may be invoked from Java code to parse mathematical expressions. It is useful for programmers developing calculators, graphing utilities or other math related programs. ...
3
by: mathieu | last post by:
Could someone please tell me what is wrong with the following -ugly- piece of c++ code. Why when I explicititely set the template parameter my gcc compiler start getting confused: bla.cxx: In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.