|
Boost : |
Subject: Re: [boost] [xint] Boost.XInt formal review (concrete complaint)
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-03-06 21:37:40
Chad Nelson wrote:
> The only concrete complaint that people could give me about CoW was
> that code using it couldn't be made thread-safe, which is true. So I
> made a way to instruct the library to force all integer objects to
> have unique storage before they're returned to user code, and made it
> the default to prevent unpleasant client-code surprises.
I don't think that this is enough to prevent surprises. If someone does
thread t( f, x );
where x is an integer, the thread would receive a shared copy of x. The user
would need to explicitly call the copy constructor with a second argument of
true to avoid that. Just use detail::atomic_count until C++0x atomics arrive
in numbers. :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk