[function] boost::function<>::swap() can throw

I was quite surprised to realize that boost::function<>::swap can throw in case a memory allocation fails. Is this intentional or a known issue? The TR1 function<>::swap is specified not to throw. thanks, -- Arvid Norberg

Arvid Norberg wrote:
I was quite surprised to realize that boost::function<>::swap can throw in case a memory allocation fails. Is this intentional or a known issue?
The TR1 function<>::swap is specified not to throw.
Pete Becker once explained at comp.std.c++:
[requiring a non-throwing swap] precludes a small-object optimization for std::tr1::function. If its swap member function is allowed to throw exceptions then it can hold small function objects internally rather than putting them on the free store
Please check out the discussion at comp.std.c++, September 2006, Re: Is a Swappable class allowed to throw an exception? http://groups.google.com/group/comp.std.c++/browse_thread/thread/4e20e432934... Still I would appreciate having a non-throwing swap for boost::function... But at least the Standard and the Boost library should be in sync! Are you going to make a ticket on this issue? Kind regards, -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center
participants (2)
-
Arvid Norberg
-
Niels Dekker - mail address until 2008-12-31