|
From: Luigi B. <lui...@gm...> - 2011-04-10 11:40:05
|
On Apr 10, 2011, at 11:02 AM, Kakhkhor Abdijalilov wrote:
> I think smart pointer is not needed, since exception objects should be
> passed by reference. Following "less is more" principle the shared
> pointer to string could be replaced by a plain string.
They are caught by reference, but thrown by copy. If you try compiling
class Foo {
public:
Foo() {}
private:
Foo(const Foo&);
};
int main() {
try {
throw Foo();
catch (Foo&) {}
return 0;
}
the compiler (well, gcc at least) will complain that the copy
constructor is private at the "throw" line.
Luigi
|