From 554c161f1fd3222e49cef94881595237f0c1624d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 25 Jun 2001 03:54:32 +0000 Subject: [PATCH] Add a helper function bind_obj llvm-svn: 70 --- llvm/include/llvm/Tools/STLExtras.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/llvm/include/llvm/Tools/STLExtras.h b/llvm/include/llvm/Tools/STLExtras.h index 525f6a014b69..39bfb4000f12 100644 --- a/llvm/include/llvm/Tools/STLExtras.h +++ b/llvm/include/llvm/Tools/STLExtras.h @@ -150,6 +150,22 @@ ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, // Extra additions to //===----------------------------------------------------------------------===// +// 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 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. //