Compaq C++ User Documentation

| United States

cxxlstd$help.HLP

##

##

##

##

##

##

##

##

    bind1st
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      bind1st, bind2nd, binder1st, binder2nd  - Templatized	utilities to
      bind values to function objects

    SYNOPSIS

      #include <functional>

      template <class Operation>
      class	binder1st : public unary_function<typename
    		    Operation::second_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder1st<Operation> bind1st (const Operation&, const	T&);

      template <class Operation>
      class	binder2nd : public unary_function<typename
    		    Operation::first_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder2nd<Operation> bind2nd (const Operation&, const	T&);

    DESCRIPTION

      Because so many functions provided by	the standard library take
      other	functions as arguments, the library includes classes  that
      let you	build new function objects out of old ones. Both
      bind1st() and bind2nd() are functions	that take as arguments a
      binary function object f and a value x, and return, respectively,
      classes binder1st and binder2nd.  The underlying function object
      must be a subclass of	binary_function.

      Class	binder1st binds	the value to the first argument	of the binary
      function,	and binder2nd does the same thing for the second
      argument  of the function.  The resulting classes can be used in
      place	of a unary predicate in other function calls.

      For example, you could use the count_if algorithm to count all
      elements  in a vector that are less than or equal to 7,  using the
      following:

      count_if (v.begin, v.end, bind1st(greater<int> (),7),	littleNums)

      This function	adds one to littleNums each time the predicate is
      true,	i.e., each time 7 is greater than the element.

    INTERFACE

      // Class binder1st
      template <class Operation>
      class	binder1st
         : public unary_function<typename
    			    Operation::second_argument_type,
    			    typename Operation::result_type>
      {
      public:

        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder1st(const Operation&,
    	      const typename Operation::first_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Class binder2nd
      template <class Operation>
      class	binder2nd
         : public unary_function<typename
    			    Operation::first_argument_type,
    			    typename Operation::result_type>
      {
      public:
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder2nd(const Operation&,
    	      const typename Operation::second_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Creator bind1st

        template <class Operation, class T>
        binder1st<Operation> bind1st (const	Operation&, const T&);

      // Creator bind2nd

        template<class Operation, class T>
        binder2nd <Operation> bind2nd(const	Operation&, const T&);

    EXAMPLE

      //
      // binders.cpp
      //
       #include <functional>
       #include <algorithm>
       #include <vector>
       #include <iostream.h>
      int main()
       {
        typedef vector<int>::iterator iterator;
        int	d1[4] =	{1,2,3,4};
         //
         //	Set up a vector
         //
        vector<int>	v1(d1,d1 + 4);
         //
         //	Create an 'equal to 3' unary predicate by binding 3 to
         //	the equal_to binary predicate.
         //
        binder1st<equal_to<int> > equal_to_3 =
           bind1st(equal_to<int>(),3);
         //
         //	Now use	this new predicate in a	call to	find_if
         //
        iterator it1 = find_if(v1.begin(),v1.end(),equal_to_3);
         //
         //	Even better, construct the new predicate on the	fly
         //
        iterator it2 =
           find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3));
         //
         //	And now	the same thing using bind2nd
         //	Same result since == is	commutative
         //
        iterator it3 =
           find_if(v1.begin(),v1.end(),bind2nd(equal_to<int>(),3));
         //
         //	it3 = v1.begin() + 2
         //
         //	Output results
         //
        cout << *it1 << " "	<< *it2	<< " " << *it3 << endl;
        return 0;
       }

      Output : 3 3 3

    WARNINGS

      If your compiler does	not support default template parameters	then
      you need to always supply the Allocator template argument.  For
      instance  you'll have to write:

      vector<int,allocator<int> > instead of:

      vector<int>

    SEE ALSO

      Function Object

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    bind2nd
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      bind1st, bind2nd, binder1st, binder2nd  - Templatized	utilities to
      bind values to function objects

    SYNOPSIS

      #include <functional>

      template <class Operation>
      class	binder1st : public unary_function<typename
    		    Operation::second_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder1st<Operation> bind1st (const Operation&, const	T&);

      template <class Operation>
      class	binder2nd : public unary_function<typename
    		    Operation::first_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder2nd<Operation> bind2nd (const Operation&, const	T&);

    DESCRIPTION

      Because so many functions provided by	the standard library take
      other	functions	as arguments, the library includes classes
      that	let you	build new function objects out of old ones. Both
      bind1st() and bind2nd()  are functions	that take as arguments
      a binary	function object	f and a	value x, and return,
      respectively,	classes	binder1st and binder2nd.   The underlying
      function object must be a subclass of	binary_function.

      Class	binder1st binds	the value to the first argument	of the binary
      function,	and binder2nd does the same thing for the second
      argument  of the function.  The resulting classes can be used in
      place	of a unary  predicate in other function calls.

      For example, you could use the count_if algorithm to count all
      elements  in a vector that are less than or equal to 7,  using the
      following:

      count_if (v.begin, v.end, bind1st(greater<int> (),7),	littleNums)

      This function	adds one to littleNums each time the predicate is
      true,	i.e., each time 7 is greater than the element.

    INTERFACE

      // Class binder1st
      template <class Operation>
      class	binder1st
         : public unary_function<typename
    			    Operation::second_argument_type,
    			    typename Operation::result_type>
      {
      public:

        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder1st(const Operation&,
    	      const typename Operation::first_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Class binder2nd
      template <class Operation>
      class	binder2nd
         : public unary_function<typename
    			    Operation::first_argument_type,
    			    typename Operation::result_type>
      {
      public:
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder2nd(const Operation&,
    	      const typename Operation::second_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Creator bind1st

        template <class Operation, class T>
        binder1st<Operation> bind1st (const	Operation&, const T&);

      // Creator bind2nd

        template<class Operation, class T>
        binder2nd <Operation> bind2nd(const	Operation&, const T&);

    EXAMPLE

      //
      // binders.cpp
      //
       #include <functional>
       #include <algorithm>
       #include <vector>
       #include <iostream.h>
      int main()
       {
        typedef vector<int>::iterator iterator;
        int	d1[4] =	{1,2,3,4};
         //
         //	Set up a vector
         //
        vector<int>	v1(d1,d1 + 4);
         //
         //	Create an 'equal to 3' unary predicate by binding 3 to
         //	the equal_to binary predicate.
         //
        binder1st<equal_to<int> > equal_to_3 =
           bind1st(equal_to<int>(),3);
         //
         //	Now use	this new predicate in a	call to	find_if
         //
        iterator it1 = find_if(v1.begin(),v1.end(),equal_to_3);
         //
         //	Even better, construct the new predicate on the	fly
         //
        iterator it2 =
           find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3));
         //
         //	And now	the same thing using bind2nd
         //	Same result since == is	commutative
         //
        iterator it3 =
           find_if(v1.begin(),v1.end(),bind2nd(equal_to<int>(),3));
         //
         //	it3 = v1.begin() + 2
         //
         //	Output results
         //
        cout << *it1 << " "	<< *it2	<< " " << *it3 << endl;
        return 0;
       }

      Output : 3 3 3

    WARNINGS

      If your compiler does	not support default template parameters	then
      you need to always supply the Allocator template argument.  For
      instance  you'll have to write:

      vector<int,allocator<int> > instead of:

      vector<int>

    SEE ALSO

      Function Object

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    binder1st
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      bind1st, bind2nd, binder1st, binder2nd  - Templatized	utilities to
      bind values to function objects

    SYNOPSIS

      #include <functional>

      template <class Operation>
      class	binder1st : public unary_function<typename
    		    Operation::second_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder1st<Operation> bind1st (const Operation&, const	T&);

      template <class Operation>
      class	binder2nd : public unary_function<typename
    		    Operation::first_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder2nd<Operation> bind2nd (const Operation&, const	T&);

    DESCRIPTION

      Because so many functions provided by	the standard library take
      other	functions	as arguments, the library includes classes
      that	let you	build new function objects out of old ones. Both
      bind1st() and bind2nd()  are functions	that take as arguments
      a binary	function object	f and a	value x, and return,
      respectively,	classes	binder1st and binder2nd.   The underlying
      function object must be a subclass of	binary_function.

      Class	binder1st binds	the value to the first argument	of the binary
      function, and binder2nd does the same thing for the second argument
      of the function.  The resulting classes can be used in place	of a
      unary predicate in other function calls.

      For example, you could use the count_if algorithm to count all
      elements  in a vector that	are less than or equal to 7,   using
      the	following:

      count_if (v.begin, v.end, bind1st(greater<int> (),7),	littleNums)

      This function	adds one to littleNums each time the predicate is
      true,	i.e., each time 7 is greater than the element.

    INTERFACE

      // Class binder1st
      template <class Operation>
      class	binder1st
         : public unary_function<typename
    			    Operation::second_argument_type,
    			    typename Operation::result_type>
      {
      public:

        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder1st(const Operation&,
    	      const typename Operation::first_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Class binder2nd
      template <class Operation>
      class	binder2nd
         : public unary_function<typename
    			    Operation::first_argument_type,
    			    typename Operation::result_type>
      {
      public:
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder2nd(const Operation&,
    	      const typename Operation::second_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Creator bind1st

        template <class Operation, class T>
        binder1st<Operation> bind1st (const	Operation&, const T&);

      // Creator bind2nd

        template<class Operation, class T>
        binder2nd <Operation> bind2nd(const	Operation&, const T&);

    EXAMPLE

      //
      // binders.cpp
      //
       #include <functional>
       #include <algorithm>
       #include <vector>
       #include <iostream.h>
      int main()
       {
        typedef vector<int>::iterator iterator;
        int	d1[4] =	{1,2,3,4};
         //
         //	Set up a vector
         //
        vector<int>	v1(d1,d1 + 4);
         //
         //	Create an 'equal to 3' unary predicate by binding 3 to
         //	the equal_to binary predicate.
         //
        binder1st<equal_to<int> > equal_to_3 =
           bind1st(equal_to<int>(),3);
         //
         //	Now use	this new predicate in a	call to	find_if
         //
        iterator it1 = find_if(v1.begin(),v1.end(),equal_to_3);
         //
         //	Even better, construct the new predicate on the	fly
         //
        iterator it2 =
           find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3));
         //
         //	And now	the same thing using bind2nd
         //	Same result since == is	commutative
         //
        iterator it3 =
           find_if(v1.begin(),v1.end(),bind2nd(equal_to<int>(),3));
         //
         //	it3 = v1.begin() + 2
         //
         //	Output results
         //
        cout << *it1 << " "	<< *it2	<< " " << *it3 << endl;
        return 0;
       }

      Output : 3 3 3

    WARNINGS

      If your compiler does	not support default template parameters	then
      you need to always supply the Allocator template argument.  For
      instance you'll have to write:

      vector<int,allocator<int> > instead of:

      vector<int>

    SEE ALSO

      Function Object

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    binder2nd
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      bind1st, bind2nd, binder1st, binder2nd  - Templatized	utilities to
      bind values to function objects

    SYNOPSIS

      #include <functional>

      template <class Operation>
      class	binder1st : public unary_function<typename
    		    Operation::second_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder1st<Operation> bind1st (const Operation&, const	T&);

      template <class Operation>
      class	binder2nd : public unary_function<typename
    		    Operation::first_argument_type,
    		    typename Operation::result_type> ;

      template <class Operation, class T>
      binder2nd<Operation> bind2nd (const Operation&, const	T&);

    DESCRIPTION

      Because so many functions provided by	the standard library take
      other	functions	as arguments, the library includes classes
      that	let you	build new function objects out of old ones. Both
      bind1st() and bind2nd()  are functions	that take as arguments
      a binary	function object	f and a	value x, and return,
      respectively,	classes	binder1st and binder2nd.   The underlying
      function object must be a subclass of	binary_function.

      Class	binder1st binds	the value to the first argument	of the binary
      function,	and binder2nd does the same thing for the second
      argument  of the function.  The resulting classes can be used in
      place	of a unary  predicate in other function calls.

      For example, you could use the count_if algorithm to count all
      elements  in a vector that	are less than or equal to 7,  using
      the	following:

      count_if (v.begin, v.end, bind1st(greater<int> (),7),	littleNums)

      This function	adds one to littleNums each time the predicate is
      true,	i.e., each time 7 is greater than the element.

    INTERFACE

      // Class binder1st
      template <class Operation>
      class	binder1st
         : public unary_function<typename
    			    Operation::second_argument_type,
    			    typename Operation::result_type>
      {
      public:

        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::second_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder1st(const Operation&,
    	      const typename Operation::first_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Class binder2nd
      template <class Operation>
      class	binder2nd
         : public unary_function<typename
    			    Operation::first_argument_type,
    			    typename Operation::result_type>
      {
      public:
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::argument_type argument_type;
        typedef typename unary_function<typename
         Operation::first_argument_type, typename
         Operation::result_type>::result_type result_type;

        binder2nd(const Operation&,
    	      const typename Operation::second_argument_type&);
        result_type	operator() (const argument_type&) const;
      };

      // Creator bind1st

        template <class Operation, class T>
        binder1st<Operation> bind1st (const	Operation&, const T&);

      // Creator bind2nd

        template<class Operation, class T>
        binder2nd <Operation> bind2nd(const	Operation&, const T&);

    EXAMPLE

      //
      // binders.cpp
      //
       #include <functional>
       #include <algorithm>
       #include <vector>
       #include <iostream.h>
      int main()
       {
        typedef vector<int>::iterator iterator;
        int	d1[4] =	{1,2,3,4};
         //
         //	Set up a vector
         //
        vector<int>	v1(d1,d1 + 4);
         //
         //	Create an 'equal to 3' unary predicate by binding 3 to
         //	the equal_to binary predicate.
         //
        binder1st<equal_to<int> > equal_to_3 =
           bind1st(equal_to<int>(),3);
         //
         //	Now use	this new predicate in a	call to	find_if
         //
        iterator it1 = find_if(v1.begin(),v1.end(),equal_to_3);
         //
         //	Even better, construct the new predicate on the	fly
         //
        iterator it2 =
           find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3));
         //
         //	And now	the same thing using bind2nd
         //	Same result since == is	commutative
         //
        iterator it3 =
           find_if(v1.begin(),v1.end(),bind2nd(equal_to<int>(),3));
         //
         //	it3 = v1.begin() + 2
         //
         //	Output results
         //
        cout << *it1 << " "	<< *it2	<< " " << *it3 << endl;
        return 0;
       }

      Output : 3 3 3

    WARNINGS

      If your compiler does	not support default template parameters	then
      you need to always supply the Allocator template argument.  For
      instance  you'll have to write:

      vector<int,allocator<int> > instead of:

      vector<int>

    SEE ALSO

      Function Object

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    mem_fun
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      mem_fun, mem_fun1, mem_fun_ref, mem_fun_ref1	- Function objects
      that	adapt a pointer to a member	function to work where a
      global	function  is called for.

    SYNOPSIS

      #include <functional>

      template <class S, class T> class mem_fun_t;
      template <class S, class T, class A> class mem_fun1_t;
      template <class S, class T> class mem_fun_ref_t;
      template <class S, class T, class A> class mem_fun1_ref_t;

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    DESCRIPTION

      The mem_fun  group of	 templates each	encapsulates a pointer to a
      member function.  Each category of template (i.e. mem_fun, mem_fun1,
      mem_fun_ref, or mem_fun1_ref) provides both a class template and a
      function template, where the class is distinguished by the addition
      of _t on the	end of the name to identify it as a type.

      The class's constructor takes	a pointer to a member function,	and
      provides an operator() that forwards the call to that member
      function. In this way the resulting object serves as a global
      function  object for that member function.

      The accompanying function template simplifies	the use	of this
      facility  by constructing an instance of the class on the fly.

      The library provides zero and	one argument adaptors for containers
      of pointers  and	containers of references (_ref).  This
      technique can be easily extended to include adaptors for two
      argument functions, and so  on.

    INTERFACE

      template <class S, class T> class mem_fun_t
    	    : public unary_function<T*,	S> {
         public:
           explicit	mem_fun_t(S (T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_t
    	    : public binary_function<T*, A, S> {
         public:
           explicit	mem_fun1_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());

      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));

      template <class S, class T> class mem_fun_ref_t
    	    : public unary_function<T, S> {
         public:
           explicit	mem_fun_ref_t(S	(T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_ref_t
    	    : public binary_function<T,	A, S> {
         public:
           explicit	mem_fun1_ref_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    EXAMPLE

      //
      // mem_fun  example
      //

      #include <functional>
      #include <list>

      int main(void)
      {
       int a1[] = {2,1,5,6,4};
       int a2[] = {11,4,67,3,14};
       list<int> s1(a1,a1+5);
       list<int> s2(a2,a2+5);

        // Build a list of lists
       list<list<int>* > l;
       l.insert(l.begin(),s1);
       l.insert(l.begin(),s2);

        // Sort each list in the list
       for_each(l.begin(),l.end(),mem_fun(&list<int>::sort));
      }

    SEE ALSO

      binary_function, function_objects, pointer_to_unary_function,
      ptr_fun

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    mem_fun1
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      mem_fun, mem_fun1, mem_fun_ref, mem_fun_ref1	- Function objects
      that	adapt a pointer to a member function to work where a global
      function is called for.

    SYNOPSIS

      #include <functional>

      template <class S, class T> class mem_fun_t;
      template <class S, class T, class A> class mem_fun1_t;
      template <class S, class T> class mem_fun_ref_t;
      template <class S, class T, class A> class mem_fun1_ref_t;

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    DESCRIPTION

      The mem_fun  group of	 templates each	encapsulates a pointer to a
      member function.  Each category of template (i.e. mem_fun, mem_fun1,
      mem_fun_ref,or mem_fun1_ref) provides both a class template and a
      function template, where the class is distinguished by the addition
      of _t on the	end of the name to identify it as a type.

      The class's constructor takes	a pointer to a member function,	and
      provides an operator() that forwards the call to that member
      function. In this way the resulting object serves as a global
      function  object for that member function.

      The accompanying function template simplifies	the use	of this
      facility  by constructing an instance of the class on the fly.

      The library provides zero and	one argument adaptors for containers
      of pointers  and	containers of references (_ref).  This
      technique can be easily extended to include adaptors for two
      argument functions, and so  on.

    INTERFACE

      template <class S, class T> class mem_fun_t
    	    : public unary_function<T*,	S> {
         public:
           explicit	mem_fun_t(S (T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_t
    	    : public binary_function<T*, A, S> {
         public:
           explicit	mem_fun1_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());

      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));

      template <class S, class T> class mem_fun_ref_t
    	    : public unary_function<T, S> {
         public:
           explicit	mem_fun_ref_t(S	(T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_ref_t
    	    : public binary_function<T,	A, S> {
         public:
           explicit	mem_fun1_ref_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    EXAMPLE

      //
      // mem_fun  example
      //

      #include <functional>
      #include <list>

      int main(void)
      {
       int a1[] = {2,1,5,6,4};
       int a2[] = {11,4,67,3,14};
       list<int> s1(a1,a1+5);
       list<int> s2(a2,a2+5);

        // Build a list of lists
       list<list<int>* > l;
       l.insert(l.begin(),s1);
       l.insert(l.begin(),s2);

        // Sort each list in the list
       for_each(l.begin(),l.end(),mem_fun(&list<int>::sort));
      }

    SEE ALSO

      binary_function, function_objects, pointer_to_unary_function,
      ptr_fun

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    mem_fun_ref
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      mem_fun, mem_fun1, mem_fun_ref, mem_fun_ref1	- Function objects
      that	adapt a pointer to a member	function to work where a
      global	function  is called for.

    SYNOPSIS

      #include <functional>

      template <class S, class T> class mem_fun_t;
      template <class S, class T, class A> class mem_fun1_t;
      template <class S, class T> class mem_fun_ref_t;
      template <class S, class T, class A> class mem_fun1_ref_t;

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    DESCRIPTION

      The mem_fun  group of	 templates each	encapsulates a pointer to a
      member function.  Each category of template (i.e. mem_fun, mem_fun1,
      mem_fun_ref, or mem_fun1_ref) provides both a class template and a
      function template, where the class is distinguished by the addition
      of _t on the	end of the name to identify it as a type.

      The class's constructor takes	a pointer to a member function,	and
      provides an operator()	that forwards the call to that member
      function. In this way the resulting object serves as a global
      function  object for that member function.

      The accompanying function template simplifies	the use	of this
      facility  by constructing an instance of the class on the fly.

      The library provides zero and	one argument adaptors for containers
      of pointers  and	containers of references (_ref).  This
      technique can be easily extended to include adaptors for two
      argument functions, and so  on.

    INTERFACE

      template <class S, class T> class mem_fun_t
    	    : public unary_function<T*,	S> {
         public:
           explicit	mem_fun_t(S (T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_t
    	    : public binary_function<T*, A, S> {
         public:
           explicit	mem_fun1_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());

      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));

      template <class S, class T> class mem_fun_ref_t
    	    : public unary_function<T, S> {
         public:
           explicit	mem_fun_ref_t(S	(T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_ref_t
    	    : public binary_function<T,	A, S> {
         public:
           explicit	mem_fun1_ref_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    EXAMPLE

      //
      // mem_fun  example
      //

      #include <functional>
      #include <list>

      int main(void)
      {
       int a1[] = {2,1,5,6,4};
       int a2[] = {11,4,67,3,14};
       list<int> s1(a1,a1+5);
       list<int> s2(a2,a2+5);

        // Build a list of lists
       list<list<int>* > l;
       l.insert(l.begin(),s1);
       l.insert(l.begin(),s2);

        // Sort each list in the list
       for_each(l.begin(),l.end(),mem_fun(&list<int>::sort));
      }

    SEE ALSO

      binary_function, function_objects, pointer_to_unary_function,	ptr_fun

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

    mem_fun_ref1
    			   Standard C++	Library
    		 Copyright 1996, Rogue Wave Software, Inc.

    NAME

      mem_fun, mem_fun1, mem_fun_ref, mem_fun_ref1	- Function objects
      that	adapt a pointer to a member function to work where a global
      function is  called for.

    SYNOPSIS

      #include <functional>

      template <class S, class T> class mem_fun_t;
      template <class S, class T, class A> class mem_fun1_t;
      template <class S, class T> class mem_fun_ref_t;
      template <class S, class T, class A> class mem_fun1_ref_t;

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    DESCRIPTION

      The mem_fun  group of	 templates each	encapsulates a pointer to a
      member function.  Each category of template (i.e. mem_fun, mem_fun1,
      mem_fun_ref, or mem_fun1_ref) provides both a class template and a
      function template, where the class is distinguished by the addition
      of _t on the	end of the name to identify it as a type.

      The class's constructor takes	a pointer to a member function,	and
      provides an operator()	that forwards the call to that member
      function. In this way the resulting	object serves as a global
      function  object for that member function.

      The accompanying function template simplifies	the use	of this
      facility  by constructing an instance of the class	on the fly.

      The library provides zero and	one argument adaptors for containers
      of pointers  and	containers of references (_ref).  This
      technique can be easily extended to include adaptors for two
      argument functions, and  so on.

    INTERFACE

      template <class S, class T> class mem_fun_t
    	    : public unary_function<T*,	S> {
         public:
           explicit	mem_fun_t(S (T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_t
    	    : public binary_function<T*, A, S> {
         public:
           explicit	mem_fun1_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };

      template<class S, class T> mem_fun_t<S,T>
        mem_fun(S, (T::*f)());

      template<class S, class T, class A> mem_fun1_t<S,T,A>
         mem_fun1(S, (T::*f)(A));

      template <class S, class T> class mem_fun_ref_t
    	    : public unary_function<T, S> {
         public:
           explicit	mem_fun_ref_t(S	(T::*p)());
           S operator()(T* p);
      };

      template <class S, class T, class A> class mem_fun1_ref_t
    	    : public binary_function<T,	A, S> {
         public:
           explicit	mem_fun1_ref_t(S (T::*p)(A));
           S operator()(T* p, A x);
      };
      template<class S, class T> mem_fun_ref_t<S,T>
          mem_fun_ref(S, (T::*f)());
      template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
          mem_fun1_ref(S, (T::*f)(A));

    EXAMPLE

      //
      // mem_fun  example
      //

      #include <functional>
      #include <list>

      int main(void)
      {
       int a1[] = {2,1,5,6,4};
       int a2[] = {11,4,67,3,14};
       list<int> s1(a1,a1+5);
       list<int> s2(a2,a2+5);

        // Build a list of lists
       list<list<int>* > l;
       l.insert(l.begin(),s1);
       l.insert(l.begin(),s2);

        // Sort each list in the list
       for_each(l.begin(),l.end(),mem_fun(&list<int>::sort));
      }

    SEE ALSO

      binary_function, function_objects, pointer_to_unary_function,	ptr_fun

    STANDARDS CONFORMANCE
      ANSI X3J16/ISO WG21 Joint C++	Committee

|  | privacy statement and legal notices