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
> 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
> 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,

Boost list run by bdawes at, gregod at, cpdaniel at, john at