Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2006-07-24 15:09:47


Boost.Function does not preserve const correctness for reference wrappers

class function_object_type {
    void operator()() const {}

void f() {
    const function_object_type const_function_object;
    boost::function<void()> function(boost::ref(const_function_object));
    assert(<function_object>() ==
&const_function_object); //const lost

I can see two possible solutions for this:

    add a flag:
    enum cv_qualifiers { const_ = 1, volatile_ = 1 << 1};

    or don't unwrap references for target:<boost::reference_wrapper<function_object> >()

The first method seems preferable because it doesn't
require the interface to change.

In Christ,
Steven Watanabe

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