Modify

Opened 11 years ago

Closed 9 years ago

#736 closed Bugs (fixed)

Const correctness violation

Reported by: Douglas Gregor Owned by: Douglas Gregor
Milestone: Component: function
Version: None Severity: Problem
Keywords: Cc:

Description (last modified by Douglas Gregor)

Boost.Function does not preserve const correctness for reference 
wrappers
e.g.

class function_object_type {
  public:
    void operator()() const {}
};

void f() {
    const function_object_type const_function_object;
    boost::function<void()> function(boost::ref(const_function_object));
    assert(function.target<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:
    function.target<boost::reference_wrapper<function_object> >()

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

In Christ,
Steven Watanabe


Attachments (0)

Change History (3)

comment:1 Changed 10 years ago by Marshall Clow

Owner: changed from Douglas Gregor to doug_gregor
Severity: Problem
Status: assignednew

Assigned to "doug_gregor" instead of nonexistent user "dgregor"

comment:2 Changed 10 years ago by Douglas Gregor

Description: modified (diff)
Owner: changed from doug_gregor to Douglas Gregor
Status: newassigned

comment:3 Changed 9 years ago by Douglas Gregor

Resolution: Nonefixed
Status: assignedclosed

(In [48618]) Make Boost.Function's target() operation respect the cv-qualifiers of referenced function objects. Fixes #736

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Douglas Gregor.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.