Topic: templates and exception specifications
Author: algrant@myrealbox.com (Al Grant)
Date: Fri, 21 Feb 2003 15:48:22 +0000 (UTC) Raw View
Why does 15.4#2 invalidate this:
template<typename T> int f(void) throw(int);
template<> int f<int>(void) throw();
on the grounds of not having the same exception specification?
It is safe in the sense that the specialization can throw fewer
exception types than its original (templated) declaration says
it can. I would expect it to have the same sort of rule as the
virtual-inheritance case or the pointer-assignment case in 15.4#3.
VC++ and g++ accept this, Comeau does not. But VC++ and g++ also
accept it the other way round which suggests they don't implement
the 15.4#2 diagnostic at all.
On a related question is this valid?
template<typename T> int f(void) throw(T); // A
template<> int f<int>(void) throw(int); // B
It ought to be, but in 15.4#2 can one rely on type-ids being
resolved as far as they can be before being matched?
---
[ 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 ]