Boost logo

Boost :

From: Jesse Jones (jejones_at_[hidden])
Date: 2000-11-29 18:09:17

>Some, but certainly not the major part. Function objects fall into three
>categories wrt state:
>(1) Stateless, eg functions, many of the function object types in the
>standard, many predicates, many transformations.
>(2) Stateful but with fixed state, eg many bound function objects, many
>of the other function object types in the library, many predicates, many
>(3) Stateful but with changeable state, eg RNGs, accumulators.
>In my experience, category (1) and (2) cover most of the uses, eg the
>callback examples cited, predicates, etc would fall into these
>categories, hence no need for synchronisation. Category (3) is the
>minority category, IME, and it is only category (3) that definitely
>requires synchronisation.

Callbacks that wrap member functions also generally fall into category 3. I
think that will be the most common use of callbacks. They're very handy for
GUI programming and other sorts of notifications. The other categories seem
most useful with template programming (eg std::transform), but I don't
think most people now or in the medium term will use callbacks much there.

  -- Jesse

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