Re: shared_ptr in Error class
Posted by
Luigi Ballabio on
Apr 10, 2011; 11:39am
URL: http://quantlib.414.s1.nabble.com/shared-ptr-in-Error-class-tp13384p13387.html
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
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev