Re: [Boost-bugs] [Boost C++ Libraries] #736: Const correctness violation

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #736: Const correctness violation
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-09-13 18:23:53


#736: Const correctness violation
----------------------+-----------------------------------------------------
  Reporter: dgregor | Owner: dgregor
      Type: Bugs | Status: assigned
 Milestone: | Component: function
   Version: None | Severity: Problem
Resolution: None | Keywords:
----------------------+-----------------------------------------------------
Changes (by dgregor):

  * owner: doug_gregor => dgregor
  * status: new => assigned

Old description:

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

> }}}

New description:

 {{{

 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


 }}}

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/736#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC