|
Boost : |
Subject: [boost] Boost.Function comparison, again
From: David Abrahams (dave_at_[hidden])
Date: 2009-07-23 09:11:23
The docs say:
When comparing against an instance of reference_wrapper, the address
of the object in the reference_wrapper is compared against the address
of the object stored by the function object wrapper:
a_stateful_object so1, so2;
f = boost::ref(so1);
assert(f == boost::ref(so1));
assert(f == so1); // Only if a_stateful_object is EqualityComparable
assert(f != boost::ref(so2));
I take it from the above that
so1 == so2 implies f == so2
function_equal(so1,so2) implies f == so2
? Neither one of those is made entirely clear from the above.
It appears that the library assumes a function object may be _stored_ by ref
f = boost::ref(so1);
for efficiency reasons, but will only be _compared_ by ref
assert(f == boost::ref(so1));
because so1 is stateful. What is the rationale for this asymmetry? Is
there a role for the is_stateless type trait in smoothing over these
bumps? Seems to me that if you know the type is stateless, comparing
addresses isn't very useful.
TIA,
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk