Re: std::packaged_task trunk problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 2, 2011 at 13:01, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
> 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()>{} );

Great, that works.

I tried to put the packaged_task into a
std::vector<std::function<void()>>, that fails.
I had to create a wrapper around the packaged_task to make it work.

-- 
        Lgb



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux