Boost logo

Boost :

Subject: Re: [boost] [atomic] (op)_and_test naming
From: Rob Stewart (rstewart_at_[hidden])
Date: 2018-01-25 11:32:15

On January 24, 2018 6:32:01 PM EST, Gavin Lambert via Boost <boost_at_[hidden]> wrote:
> On 25/01/2018 00:35, Andrey Semashev wrote:
> > I would like to ask for the community opinion on the naming of the
> > (op)_and_test functions that appeared in Boost.Atomic 1.66.
> For clarity, I was the one who filed the issue mentioned in the OP.
> My argument is the following:
> * "if (x)" is true when x is an integer type that is nonzero. (And
> this convention is often extended to non-integer types as well, for
> suitable definitions of "zero".)
> * "atomic_flag::test_and_set" is true when the flag was previously
> set.
> * "atomic<T>::bit_test_and_set" is true when the bit was previously
> 1/set.
> * "atomic<T>::fetch_add" returns the value prior to the add, which is
> true if nonzero due to the first rule.
> It thus seems peculiar to have "atomic<>::add_and_test" return true
> when the result is zero.

Your consistency argument seems compelling, unless there are unidentified counterexamples.

(Sent from my portable computation device.)

Boost list run by bdawes at, gregod at, cpdaniel at, john at