Add a helper function bind_obj

llvm-svn: 70
This commit is contained in:
Chris Lattner 2001-06-25 03:54:32 +00:00
parent 3fe4504c28
commit 554c161f1f
1 changed files with 16 additions and 0 deletions

View File

@ -150,6 +150,22 @@ ValueType reduce_apply2(InputIt First, InputIt Last, Function Func,
// Extra additions to <functional>
//===----------------------------------------------------------------------===//
// bind_obj - Often times you want to apply the member function of an object
// as a unary functor. This macro is shorthand that makes it happen less
// verbosely.
//
// Example:
// struct Summer { void accumulate(int x); }
// vector<int> Numbers;
// Summer MyS;
// for_each(Numbers.begin(), Numbers.end(),
// bind_obj(&MyS, &Summer::accumulate));
//
// TODO: When I get lots of extra time, convert this from an evil macro
//
#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ)
// bitwise_or - This is a simple functor that applys operator| on its two
// arguments to get a boolean result.
//