Topic: Strange template parameter deduction scenario
Author: salotia@yahoo.com (Samar Lotia)
Date: Sat, 29 Mar 2003 23:48:38 +0000 (UTC) Raw View
The following bit of code compiles okay on MSVC 7, but fails on IBM
VACPP 5.x, Sunpro 5.3, HP aCC 3.30.
template <typename T>
class A
{
public:
T t;
};
template <typename C>
class ATraits
{
public:
typedef A<C> a_type;
};
class B
{
public:
template <typename C>
static void foo(const typename ATraits<C>::a_type&) {}
};
int main()
{
A<char> a;
B::foo(a);
return 0;
}
If I change the call to B::foo by making the template parameter
explicit, everything works okay, as expected, i.e.
B::foo<char>(a);
Wondering if this kind of template parameter deduction (ala MSVC 7) is
supposed to be valid according to the standard?
Thanks,
Samar Lotia
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: hyrosen@mail.com (Hyman Rosen)
Date: Sun, 30 Mar 2003 06:25:48 +0000 (UTC) Raw View
Samar Lotia wrote:
> Wondering if this kind of template parameter deduction (ala MSVC 7) is
> supposed to be valid according to the standard?
No. Conceptually, the compiler would need to search through an
infinite set of types C to find those for which ATraits<C>::a_type
was an A<char>.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]