|
Boost Users : |
Subject: Re: [Boost-users] [LockFree] a queue of std::shared_ptr?
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2013-02-22 11:14:24
2013/2/12 Michael Caisse <mcaisse-lists_at_[hidden]>
> On 02/11/2013 04:04 PM, Scott Smedley wrote:
>
>> Hi all,
>>
>> Is it possible to store std::shared_ptr objects in a
>> boost::lockfree::queue?
>>
>> eg. boost::lockfree::queue<std::**shared_ptr<Message>> q;
>>
>> Hi Scott -
>
> Lockfree queues require that the queued type (T) meets the following
> requirements:
>
> o T must have a copy constructor
> o T must have a trivial assignment operator
> o T must have a trivial destructor
>
>
> shared_ptr has neither a trivial assignment operator or destructor and
> cannot be used in the lockfree containers.
>
> michael
>
Hello,
I'm curious: suppose T is a type, that meets requirements for lockfree
queues. Does optional<T> meet those requirements?
a) Does optional<T> have a copy constructor? Yes.
b) Does optional<T> have a trivial assignment operator? Well, the
assignment is user-written in optional, but it's observable effect is
equivalent to memcpy, isn't it?
c) Does optional<T> have a trivial destructor? Well, optional's destructor
conditionally calls T's destructor, which is trivial. So is a destructor
trivial, if all it does is conditionally call a trivial destructor?
Regards,
Kris
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net