This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::packaged_task trunk problem


On Wed, Nov 2, 2011 at 13:01, Jonathan Wakely <jwakely.gcc@gmail.com> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]