Subject: Re: [boost] [container] locking for compact map
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2014-12-09 14:59:26
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
> >> issue.
> > 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.
JoaquÃn M LÃ³pez MuÃ±oz
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk