T
ThosRTanner
Having had a look at ways of passing exceptions from one thread to
another, whilst trying to keep the "catch by const ref" coding standard
alive, I've ended up making a class from which exceptions thrown in the
1st thread should inherit from, which has 3 virtual functions (clone,
which appears to be pretty standard, raise (just does throw *this), and
another), which are all utterly trival. However, these 3 trivial
functions have to be implemented in every derived class, or bad things
will happen.
OK, I can ensure that the functions are implemented in every
immediately derived class by making them pure virtual, but if a class
is 2 levels away, how do I ensure that that class implements these
funcions as well?
The other issue is writing 3 functions that are almost line for line
copies of what was written last time - this almost calls for either a
macro or some sort of template. However, I don't think templates quite
do what I want (especially as the raise() function does "throw *this"
so will probably end up throwing the wrong exception if the real class
inheris from a template).
If I don't provide some sort of functionality that makes this trivially
easy, derived classes could result in nasty errors with exceptions
being sliced.
Any ideas?
Thanks
another, whilst trying to keep the "catch by const ref" coding standard
alive, I've ended up making a class from which exceptions thrown in the
1st thread should inherit from, which has 3 virtual functions (clone,
which appears to be pretty standard, raise (just does throw *this), and
another), which are all utterly trival. However, these 3 trivial
functions have to be implemented in every derived class, or bad things
will happen.
OK, I can ensure that the functions are implemented in every
immediately derived class by making them pure virtual, but if a class
is 2 levels away, how do I ensure that that class implements these
funcions as well?
The other issue is writing 3 functions that are almost line for line
copies of what was written last time - this almost calls for either a
macro or some sort of template. However, I don't think templates quite
do what I want (especially as the raise() function does "throw *this"
so will probably end up throwing the wrong exception if the real class
inheris from a template).
If I don't provide some sort of functionality that makes this trivially
easy, derived classes could result in nasty errors with exceptions
being sliced.
Any ideas?
Thanks