diff --git a/mem_fn.html b/mem_fn.html index ed284be..25af8b2 100644 --- a/mem_fn.html +++ b/mem_fn.html @@ -45,7 +45,9 @@ boost::mem_fn is a generalization of the standard functions std::mem_fun and std::mem_fun_ref. It supports member function pointers with more than one argument, and the returned function object can take a pointer, a - reference, or a smart pointer to an object instance as its first argument. + reference, or a smart pointer to an object instance as its first argument. mem_fn + also supports pointers to data members by treating them as functions taking no + arguments and returning a (const) reference to the member.

The purpose of mem_fn is twofold. First, it allows users to invoke a @@ -87,8 +89,8 @@ template<class It, class R, class T> void for_each(It first, It last, R (T documentation of bind for an example.

- mem_fn takes one argument, a pointer to a member function, and returns a - function object suitable for use with standard or user-defined algorithms: + mem_fn takes one argument, a pointer to a member, and returns a function + object suitable for use with standard or user-defined algorithms:

 struct X
@@ -136,7 +138,8 @@ void k(std::vector<boost::shared_ptr<X> > const & v)
 		

All function objects returned by mem_fn expose a result_type typedef - that represents the return type of the member function. + that represents the return type of the member function. For data members, result_type + is defined as a const reference to the type of the member.

Frequently Asked Questions

Can mem_fn be used instead of the standard std::mem_fun[_ref] @@ -176,12 +179,14 @@ void k(std::vector<boost::shared_ptr<X> > const & v) namespace boost { -template<class T> T * get_pointer (T * p); +template<class T> T * get_pointer(T * p); template<class R, class T> unspecified-1 mem_fn(R (T::*pmf) ()); template<class R, class T> unspecified-2 mem_fn(R (T::*pmf) () const); +template<class R, class T> unspecified-2-1 mem_fn(R T::*pm); + template<class R, class T, class A1> unspecified-3 mem_fn(R (T::*pmf) (A1)); template<class R, class T, class A1> unspecified-4 mem_fn(R (T::*pmf) (A1) const); @@ -196,11 +201,12 @@ template<class R, class T, class A1, class A2> unspecified-6

Common requirements

- All unspecified-N types mentioned in the Synopsis - are CopyConstructible and Assignable. Their copy constructors and - assignment operators do not throw exceptions. unspecified-N::result_type - is defined as the return type of the member function pointer passed as an - argument to mem_fn (R in the Synopsis.) + All unspecified-N types mentioned in the Synopsis are CopyConstructible + and Assignable. Their copy constructors and assignment operators do not + throw exceptions. unspecified-N::result_type is defined as the + return type of the member function pointer passed as an argument to mem_fn + (R in the Synopsis.) unspecified-2-1::result_type is + defined as R const &.

get_pointer

template<class T> T * get_pointer(T * p)

@@ -213,8 +219,8 @@ template<class R, class T, class A1, class A2> unspecified-6

mem_fn

-

template<class R, class T> unspecified-1 - mem_fn(R (T::*pmf) ())

+

template<class R, class T> unspecified-1 mem_fn(R + (T::*pmf) ())

Returns: a function object f such that the expression f(t) @@ -225,8 +231,8 @@ template<class R, class T, class A1, class A2> unspecified-6 Throws: Nothing.

-

template<class R, class T> unspecified-2 - mem_fn(R (T::*pmf) () const)

+

template<class R, class T> unspecified-2 mem_fn(R + (T::*pmf) () const)

Returns: a function object f such that the expression f(t) @@ -238,8 +244,20 @@ template<class R, class T, class A1, class A2> unspecified-6 Throws: Nothing.

-

template<class R, class T, class A1> unspecified-3 - mem_fn(R (T::*pmf) (A1))

+

template<class R, class T> unspecified-2-1 mem_fn(R + T::*pm)

+
+

+ Returns: a function object f such that the expression f(t) + is equivalent to t.*pm when t is of type T [const] + or derived, get_pointer(t)->*pm otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T, class A1> unspecified-3 mem_fn(R + (T::*pmf) (A1))

Returns: a function object f such that the expression f(t, a1) @@ -250,8 +268,8 @@ template<class R, class T, class A1, class A2> unspecified-6 Throws: Nothing.

-

template<class R, class T, class A1> unspecified-4 - mem_fn(R (T::*pmf) (A1) const)

+

template<class R, class T, class A1> unspecified-4 mem_fn(R + (T::*pmf) (A1) const)

Returns: a function object f such that the expression f(t, a1)