std::packaged_task trunk problem

Jonathan Wakely jwakely.gcc@gmail.com
Wed Nov 2 12:01:00 GMT 2011


On 2 November 2011 11:22, Jonathan Wakely wrote:
> On 2 November 2011 10:03, Jonathan Wakely wrote:
>> On 2 November 2011 09:06, Jonathan Wakely wrote:
>>> On 2 November 2011 02:01, Lars Gullik Bjønnes wrote:
>>>>
>>>> Now of to next problem on how to store a std::packaged_task in a container.
>>>
>>> That should work because packaged_task is nothrow move constructible,
>>> but it looks as though there may be a problem with the
>>> _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR code ... I'd better look into
>>> that too.
>>>
>>
>> is_nothrow_move_constructible<packaged_task<T>>::value is false,
>> because packaged_task's destructor is not noexcept.  I'm not sure yet
>> if that's correct or not...
>
> It's correct that
> is_nothrow_move_constructible<packaged_task<T>>::value is false, but
> that shouldn't prevent it being stored in a container. I'll file a
> bugzilla report.

Bah, I think my first test was flawed - it works storing them in
containers if you only use the members that support MoveInsertable

i.e. this fails as it requires CopyInsertable:
vector<packaged_task<void()>> v{ packaged_task<void()>{} };

this is OK, it only requires MoveInsertable:
vector<packaged_task<void()>> v;
v.push_back( packaged_task<void()>{} );



More information about the Gcc-help mailing list