|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-14 12:53:49
From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
> >
> >Well, I am not a compiler writer, but it seems to me that to implement
> >"throw;" and "catch", the compiler already needs a way to copy the
> >exception, complete with its original type. :-)
>
> I don't see that at all. The catch() clause specifies the type it's
> expecting and it will be copied and sliced if need be to match.
Quiz: what does this program do?
#include <iostream>
struct X
{
};
struct Y: public X
{
};
void f()
{
try
{
throw Y();
}
catch(X)
{
throw;
}
}
int main()
{
try
{
f();
}
catch(Y)
{
std::cout << "Caught an Y!\n";
}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk