Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2001-04-10 18:34:45


> > 6) Trying to invoke an empty function seems like a precondition
>> violation to me. Asserting instead of throwing seems preferable.
>
>I disagree because using an assertion means that the check might be turned
>off. If that happens, any_function will cause a segmentation violation. At
>least throwing an exception gives some form of recovery.

Would you also throw if someone passed a nil char* into std::string's
ctor? Indexed past the end of a std::array? Passed bogus iterators
into std::find? Personally I don't think any of these should throw:
they should assert whenever possible and follow the normal code path
thereafter. This is *exactly* what asserts are for.

>
>> 9) The void* conversion operator allows for comparisons. This sounds
>> OK to me, but the current implementation won't produce meaningful
>> results.
>
>It can be made not to link with a better-matching, undefined version of
>operator==:
>
> template<typename F1R, typename F1T1, typename F1T2, typename F1T3,
> typename F1T4, typename F1T5, typename F1T6, typename F2R,
> typename F2T1, typename F2T2, typename F2T3,
> typename F2T4, typename F2T5, typename F2T6>
> bool operator==(
> const any_function<F1R, F1T1, F1T2, F1T3, F1T4, F1T5, F1T6>&,
> const any_function<F2R, F2T1, F2T2, F2T3, F2T4, F2T5, F2T6>&);
>
>Similarly for other operations that are valid with const void*.

Check. It would be nice to support operator==() though. Of course
that requires support from the underlying functors...

   -- Jesse


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