Boost logo

Boost :

From: gregod_at_[hidden]
Date: 2001-12-03 11:36:20


--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> Hi,
>
> For most applications, one wouldn't care that the constructor of
> boost::function<> might throw an exception. In my case, however, I
need to
> ensure that it won't. I think I understand why dynamic allocation is
> neccessary to boost::function, but I think there's a wide class of
> applications for which it shouldn't be neccessary. I'm thinking of
> operations which need to use a function object, but don't need to
store it
> (think for example of a suite of algorithms operating on a
particular type
> of iterator).
>
> How far is boost::function from being able to provide this sort of
> functionality?

I've just checked in some updates to boost::function to support stored
a reference-to-function object. The syntax is:

  boost::function<...> f(ref(x));

f will store a reference to x, not a copy, and the constructor call
when given a reference will not throw. Testcases & docs have been
updated to reflect the change.

As always, feedback is welcome.

  Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk