Boost logo

Boost :

From: Mac Murrett (mmurrett_at_[hidden])
Date: 2001-11-29 14:15:00


> No. It is common to introduce types that support only some
> of the available operations on built-in types. Think of
> iterators. I find ++ and -- to be the most natural C++
> expression of the counter concept.

I agree with this, but also with what Bill has been saying all along.
However, the idea of a type being threadsafe is a little silly to me.
Rather, why not have generic functions such as:

template<class Int>
void increment_atomic(Int &rValue);

This allows us also to specialize more than one type of integer, and also
remove any synchronization code if threads are not available.

The implementation of these functions can be a little tricky for the general
case, but I suspect that we can pull this off, possibly with something like:

template<class Int>
void register_atomic(const Int &value);

This can be inlined to nothing for type/platform combinations that have
intrinsic support for atomic incrementation of that type, or can create a
mutex and store it for later use for other types.

Mac.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk