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
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