Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-11-19 15:04:53

In message <v03110707b63b8d853ca4@[]>, Jesse Jones
<jejones_at_[hidden]> writes
>>What should a functor do, then, if it gets a NULL pointer? The options
>>I currently see are:
>> 1) Immediatly throw an exception.
>> 2) Throw an exception when the function call operation is
>> invoked.
>> 3) Don't dereference, but don't complain.
>4) Constructing a callback with a NULL function pointer is a precondition
>violation. Ideally an assert would fire or an exception would be thrown.
>IMO the exact behavior is a policy decision that client programmers should
>be able to affect and it's something that needs to be addressed in boost as
>a whole.

Sort of agreed: do we take the mystical and nebulous "undefined
behaviour" route, trap the behaviour only in debug builds, require
exceptions, or act with silent complacency?

The first three all constitute precondition violations: It is the matter
of policy and response in which they vary.

At the very least, having these options enumerated in Boost guidelines
might be of help to authors and users to clarify their thinking.


  Kevlin Henney phone: +44 117 942 2990
  Curbralan Limited mobile: +44 7801 073 508
  mailto:kevlin_at_[hidden] fax: +44 870 052 2289

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