Re: [Boost-bugs] [Boost C++ Libraries] #7718: Basic rvalue and C++11 support (part 2)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7718: Basic rvalue and C++11 support (part 2)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-01-21 08:10:28


#7718: Basic rvalue and C++11 support (part 2)
---------------------------+------------------------------------------------
  Reporter: apolukhin | Owner: ebf
      Type: Patches | Status: reopened
 Milestone: Boost 1.53.0 | Component: variant
   Version: Boost 1.52.0 | Severity: Optimization
Resolution: | Keywords:
---------------------------+------------------------------------------------

Comment (by apolukhin):

 First of all, I also dislike that 'new' call in move constructor, but I
 just do not see a better solution. Let me explain:

 Replying to [comment:16 djowel]:
> BTW, that "No" is in reply to "won't the user be confused by v2 holding
 an int (instead of recursive_wrapper)?".
>
> Perhaps there's a way to implement it without friend access, but I'm not
 sure. Anyway, the extra code is mostly TMP code for checking the the
 "blank" type.
>
> nullable_recursive_wrapper is a good idea, but there's this extra check
 for null on all access that makes it less optimal. And that null check
 will be there to make the 0.0000001% of the cases happy.

 I'm trying to point, that solution that makes variant change its internal
 type is as good/bad for user, as a solution with nulling the pointer of
 recursive_wrapper. But nulling the pointer is much more easy to implement.

 Here is some comparison of solutions (as I see it):

 Nulling pointer after move constructor: [[BR]]
 1) fast and efficient [[BR]]
 2) triggers an assert when user tries to reuse moved object [[BR]]
 3) must have a BOOST_ASSERT in get_pointer() finction [[BR]]
 4) easy to implement [[BR]]
 5) optimization will be used even if varinat has no type with trivial
 default constructor [[BR]]
 [[BR]]
 Make varinat change its internal type: [[BR]]
 1) fast and efficient [[BR]]
 2) obscures user, when he tries to reuse moved object [[BR]]
 3) requires a few more assignments in variant for which_ and maybe for
 trivial type construction [[BR]]
 4) hard to implement [[BR]]
 5) optimization will be used only if varinat has no type with trivial
 default constructor [[BR]]
 [[BR]]

> I don't know what you mean by lazy_recursive_wrapper. Same thing?

 It is an implementation, that after move does a lazy default construction
 of value on request.
 [[BR]]

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7718#comment:17>
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:11 UTC