Topic: N2179 suggestion
Author: edd@nunswithguns.net
Date: Mon, 25 Jun 2007 00:51:15 CST Raw View
Hi,
As far as I can tell, N2179 specifies what is currently the preferred
machinery for catching and re-throwing an exception from a child
thread:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html
However, this kind of thing would also be useful in context of unit
testing. For example, a test might be considered a failure if an
exception is thrown during its execution. In such an instance, it
would be useful to be able to identify the type of that exception.
So I'd like to see an additional function or equivalent that returns a
const std::type_info* that identifies the type of object "pointed to"
by the result of std::current_exception(), or a null-valued pointer if
there is no current exception.
Perhaps something like:
namespace std {
// N2179 as it is
// ...
const std:type_info *current_exception_type();
}
I realise that theoretically std::type_info isn't incredibly useful
for representing a type of object but in reality the name() member
function returns something useful, at least on the compilers I use.
Incidentally "option 2" in N2107 would allow this through its
typeid(...) construct:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2107.html
So is this a half-way sensible suggestion? Or would there be another
way to get the current exception's type_info?
Kind regards,
Edd
---
[ 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.comeaucomputing.com/csc/faq.html ]