diff --git a/doc/tutorial.xml b/doc/tutorial.xml index 563946f..0f011e4 100644 --- a/doc/tutorial.xml +++ b/doc/tutorial.xml @@ -274,7 +274,7 @@ f(&x, 5);
- References to Functions In some cases it is + References to Function Objects In some cases it is expensive (or semantically incorrect) to have Boost.Function clone a function object. In such cases, it is possible to request that Boost.Function keep only a reference to the actual function @@ -321,5 +321,37 @@ using references to function objects, Boost.Function will not throw exceptions during assignment or construction.
+ +
+ Comparing Boost.Function function objects + + Function object wrappers can be compared via == + or != against any function object that can be stored + within the wrapper. If the function object wrapper contains a + function object of that type, it will be compared against the given + function object (which must be + EqualityComparable). For instance: + + int compute_with_X(X*, int); + +f = &X::foo; +assert(f == &X::foo); +assert(&compute_with_X != f); + + 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)); + +
+