Topic: default template arguments in functions
Author: a9804814@unet.univie.ac.at (Thomas Mang)
Date: Fri, 11 Oct 2002 21:25:52 +0000 (UTC) Raw View
Hi everybody,
I have just found out that I cannot use default template arguments in
conjunction with free functions:
template <class T, class U = int>
void foo ()
{
// impl uses T and U;
}
This is illegal, default template arguments can only be used for
classes.
Now what shall this restriction be good for?
I can imagine it to be restricted so the implicit template argument
deduction is somewhat easier, but this case only applies to functions
that have the default-template type as part of their arguments. Here,
explicitly mentioning the template arguments may be appropriate.
Also, a quick look to Tc++PL, special edition, page 340 showes an
example of default template arguments in free (namespace-scope)
functions. Seems I was not the only one believing this to be valid!
Would be nice to include default-template arguments in free function
to next C++x0.
best regards,
Thomas
---
[ 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 ]