diff options
author | Chris Lattner <sabre@nondot.org> | 2001-06-25 03:54:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-06-25 03:54:32 +0000 |
commit | 3704c8cfff18518924e2e7206a16b0b12f783d7e (patch) | |
tree | 80772c718e1a4d89e5e34a051794a424f22493a1 | |
parent | 4dd88f6fbf6dc44ceba03b34aeab458536789b98 (diff) |
Add a helper function bind_obj
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Tools/STLExtras.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/Tools/STLExtras.h b/include/llvm/Tools/STLExtras.h index 525f6a014b..39bfb4000f 100644 --- a/include/llvm/Tools/STLExtras.h +++ b/include/llvm/Tools/STLExtras.h @@ -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. // |