https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69354

            Bug ID: 69354
           Summary: std::thread doesn't support move-only callable objects
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anthony.ajw at gmail dot com
  Target Milestone: ---

Created attachment 37390
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37390&action=edit
move_only_thread.cpp

Trying to construct a std::thread with a move-only function object produces a
compilation failure in tuple. This should compile OK.

The attached example fails with the error message below:

In file included from /usr/include/c++/5/functional:55:0,
                 from /usr/include/c++/5/thread:39,
                 from move_only_thread.cpp:1:
/usr/include/c++/5/tuple: In instantiation of ‘struct std::_Head_base<0ul,
MoveOnly, true>’:
/usr/include/c++/5/tuple:339:12:   required from ‘struct std::_Tuple_impl<0ul,
MoveOnly>’
/usr/include/c++/5/tuple:463:11:   required from ‘class std::tuple<MoveOnly>’
/usr/include/c++/5/functional:1534:39:   required from ‘struct
std::_Bind_simple<MoveOnly()>’
/usr/include/c++/5/thread:137:59:   required from
‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = MoveOnly;
_Args = {}]’
move_only_thread.cpp:16:31:   required from here
/usr/include/c++/5/tuple:64:17: error: ‘constexpr std::_Head_base<_Idx, _Head,
true>::_Head_base(const std::_Head_base<_Idx, _Head, true>&) [with long
unsigned int _Idx = 0ul; _Head = MoveOnly]’ declared to take const reference,
but implicit declaration would take non-const
       constexpr _Head_base(const _Head_base&) = default;

Reply via email to