Subject: Re: [boost] [container] locking for compact map
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-12-09 17:32:52
Le 09/12/14 20:59, Joaquin M Lopez Munoz a Ã©crit :
> Vicente J. Botet Escriba <vicente.botet <at> wanadoo.fr> writes:
>> Le 09/12/14 09:41, Joaquin M Lopez Munoz a Ã©crit :
>>> Vicente J. Botet Escriba <vicente.botet <at> wanadoo.fr> writes:
>>>> * The move constructor is not noexcept.
>>>> An implementation using vector<optional<T>> should avoid this last
>>> Or just a pointer to array, which is somewhat more efficient.
>> Why not.
> Well, on second thought this is not that easy. Moving from a to b must
> leave a in a *valid* position, which here means that either you must
> allocate a new array for a (which makes moving non-noexcept) or assign
> it a null pointer and deal with the situation in the rest of the interface,
> which is a kind of a bummer --for instance, as having size()==N is
> an invariant of the class, even const functions such as cbegin() or cend()
> need to check for null pointer and allocate accordingly, becoming
> non-nonexcept, thread unsafe and whatnot.
> So, I think your deign shouldn't try to be move-aware, much as std::array
> is not either.
I'm one of those that think that the single things we are able to do
with a moved variable is reassigning and destroying :(.