Topic: Template type deduction query


Author: bparker@gil.com.au (Brian Parker)
Date: 1997/03/07
Raw View
I have a query concerning the template type deduction rules in the Dec
96 draft standard.
I would like to use a template function like this-
template<class T>
void f( A<B<T>, C<T> >);
where A, B & C are previously defined template classes of 2, 1 & 1
parameters respectively.
My question is- can type T be deduced in the call
 A<B<int>, C<int> >a;
 f(a);
? The draft standard page 14-38 14.8.2 clause 9 states that T can be
deduced for class-template-name<T>, but the term "class-template-name"
is not defined anywhere (at least I can't find it). The parameter to
the function above is essentially a template type of one parameter T
and so I would expect that it would not be any more difficult to
deduce T than for simple template type. Can anyone elucidate this?
Furthermore, assuming T can not be deduced, what if I add an easy-to-
deduce type as the first parameter of function f i.e.
template<class T>
void f( B<T>,   A<B<T>, C<T> >); ? Given that T can definitely be
deduced from the first parameter, is T then deducable for f? Clause 10
allows this in the specific case of a nested type definition, but
clause 2 would seem to disallow it in this case.
Any comments would be be appreciated; some template-intensive code I
am developing would certainly benefit if "class-template-name" meant
"any previously defined template type".

Thanks,
Brian Parker (bparker@gil.com.au)
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]