[Boost-bugs] [Boost C++ Libraries] #6174: packaged_task does correctly handle moving results

Subject: [Boost-bugs] [Boost C++ Libraries] #6174: packaged_task does correctly handle moving results
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-25 12:37:57


#6174: packaged_task does correctly handle moving results
-------------------------------------+--------------------------------------
 Reporter: onlyone@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost Development Trunk | Severity: Showstopper
 Keywords: move packaged_task |
-------------------------------------+--------------------------------------
 I want to create a packaged task which wraps a function which returns an
 object which is movable but non-copyable. I tried:

 {{{
 #include <boost/thread.hpp>
 struct MovableButNonCopyable {
     MovableButNonCopyable() = default;
     MovableButNonCopyable(MovableButNonCopyable const&) = delete;
     MovableButNonCopyable& operator=(MovableButNonCopyable const&) =
 delete;
     MovableButNonCopyable(MovableButNonCopyable&&) = default;
     MovableButNonCopyable& operator=(MovableButNonCopyable&&) = default;
 };
 int main()
 {
     boost::packaged_task<MovableButNonCopyable>([]{return
 MovableButNonCopyable();});
 }
 }}}

 This does not compile, because the instantiation of `packaged_task`
 results in the generation of a function that attempts to call the deleted
 copy constructor for `MovableButNonCopyable`.

 I have determined that this is due to a bug at `future.hpp:325`, where an
 rvalue-to-lvalue decay is allowed to occur, which results in the incorrect
 function overload being used. A patch is attached which adds the required
 cast.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6174>
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:07 UTC