VC7.1: Parser bug with overloaded function templates

H

Hendrik Schober

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

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

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

Carl Daniel [VC++ MVP]

Hendrik said:
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
 
H

Hendrik Schober

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

Thanks, Carl!


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top