Re: [Boost-bugs] [Boost C++ Libraries] #3977: Compile error on make_nvp with reference data member

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3977: Compile error on make_nvp with reference data member
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-04 11:09:42


#3977: Compile error on make_nvp with reference data member
----------------------------------+-----------------------------------------
  Reporter: kondo@… | Owner: ramey
      Type: Patches | Status: reopened
 Milestone: Boost 1.43.0 | Component: serialization
   Version: Boost 1.42.0 | Severity: Problem
Resolution: | Keywords:
----------------------------------+-----------------------------------------
Changes (by kondo@…):

  * status: closed => reopened
  * resolution: invalid =>

Comment:

 Thank you for a quick answer.

> It's telling you not to pass a non-const.
> try fixing it with a const_cast instead.

 You're right.

 I used the static_cast, and it works correctly.
 {{{
 #!cpp
   ar << boost::serialization::make_nvp("ref_", static_cast<MyInt * const
 &>(&p->ref_));
 }}}

> Your fix will actually create an error in some instances.
> The test suite doesn't test this specifically.


 Oh, I overlooked the side effect.

 My overload matches to temporary object that shouldn't match.
 {{{
 #!cpp
 boost::serialization::make_nvp("MyInt", MyInt());
 }}}

 I still think that I can remove the cast from the client code without a
 side effect.

 I improved my patch to match only object that should
 match.(nvp_const_ref_ptr_special.patch)

 It matches only address of object, it no longer doesn't match temporary
 objects.

 How do you think about it?

 Of course I carried out all tests again.

 And all of them succeeded.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3977#comment:4>
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:50:02 UTC