Boost logo

Boost Users :

Subject: Re: [Boost-users] Equality comparison of boost::function<>
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-08-10 14:17:56


AMDG

Zachary Turner wrote:
> On Mon, Aug 10, 2009 at 10:51 AM, Steven Watanabe<watanabesj_at_[hidden]> wrote:
>
>> This ought to return false because the types are different.
>>
>>
>>> So in short, what is the flaw in just testing the way two function
>>> objects are represented internally
>>>
>> It would be surprising, because nothing else works that way.
>>
>
> I agree it might be surprising from an implementation standpoint. But
> are there examples of functors such that equality implemented this way
> would return a surprising result?

boost::lambda::_1 == std::string()

The result of memcmp depends on the implementation details of
std::string.

> If the result isn't surprising,
> then I don't think the implementation should matter much, as long as
> it relies only on standards conformant language aspects.
>

memcmp is not guaranteed to produce sensible results in this
context. I don't know that it is even guaranteed to work for
POD types, when padding is added for alignment reasons.

> Again I could just be overlooking something due to lack of
> understanding of the implementation details of boost::function<>, but
> at least on the surface it seems to me that the behavior would always
> produce expected results

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net