Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-10-08 06:55:43


From: "Douglas Gregor" <gregod_at_[hidden]>
> Thanks to some insight from Brad King, I've introduced additional syntax
into
> Boost.Function that makes function<..> instances act more like function
> pointers. Assignment to and comparison with zero is now supported, e.g.:
>
> function<int (int x, int y)> f;
> f = std::plus<int>();
> assert(f != 0); // same as assert(!f.empty())
> f = 0; // same as f.clear()
> assert(0 == f); // same as assert(f.empty());

What is the rationale for the change?

> This change is source-compatible but not necessarily binary-compatible
with
> older versions on Boost.Function. Nonetheless, it was only made on the CVS
> trunk (not the branch), and will appear in 1.30.0.

Actually I have a regression to report. Since function::operator= takes a
non-const operand, this code now fails:

#include <boost/function.hpp>

typedef boost::function< void * (void * reader) > reader_type;
typedef std::pair<int, reader_type> mapped_type;

int main()
{
    mapped_type m;
    m = mapped_type();
}

as std::pair's implicit assignment operator takes a non-const reference,
too.


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