Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-06-08 12:44:23


On Friday 08 June 2001 11:57 am, you wrote:
[snip]
> Darin:
> >>>> The code that says "// Poison comparisons between functions" declares
> >>>> but does not define the == and != operators. Is this better than
> >>>> simply
> >>>> not defining the == and != operators for these particular parameter
> >>>> types? If this poisoning is necessary for == and !=, why isn't it
> >>>> necessary for other operators? Is there some way to make comparisons
> >>>> between functions fail at compile time rather than link time?
>
> Doug:
> >>> Good point... yes, I can make the operators private members of
> >>> boost::function so using them would fail at compile time.
>
> There may be a slight problem with making them private members. I think
> they won't be used if conversion is needed on the left side, which could
> open a loophole.

I should have reviewed the code more thoroughly before my original response.
The poisoned operator declarations were:

void operator==(const function_base&, const function_base&);
void operator!=(const function_base&, const function_base&);

Note the return type. If the user attempts to use the result of one of the
equality errors it will result in a compile-time error (can't convert void to
bool). If the user has code like this:
f1 == f2;
then it will be a runtime error. This is not as likely an abuse.

> --------
>
> After hearing more discussion on the point, I still object to adding boost:
> :nil or boost::null as part of the function library.
>
> Add boost::null and boost::null_t on its own merits? Sure.
>
> Make the function library support it when it's added? Yes.
>
> Add it as part of the function library? I don't think there's a compelling
> reason to do so.
>
> -- Darin

        Doug


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