The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Интерактивная система просмотра системных руководств (man-ов)

 ТемаНаборКатегория 
 
 [Cписок руководств | Печать]

mem_fun (3)
  • >> mem_fun (3) ( Solaris man: Библиотечные вызовы )
  • 
                           Standard C++ Library
                 Copyright 1998, Rogue Wave Software, Inc.
    
    
    NAME
         mem_fun, mem_fun1, mem_fun_ref, mem_fun_ref1
    
          - Function objects that adapt a pointer to a  member  func-
         tion, to take the place of a global function.
    
    
    
    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> class const_mem_fun_t;
         template <class S, class T, class A> class const_mem_fun1_t;
         template <class S, class T> class const_mem_fun_ref_t;
         template <class S, class T, class A>
                  class const_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));
    
         template<class S, class T> const_mem_fun_t<S,T>
           mem_fun(S, (T::*f)() const);
         template<class S, class T, class A> const_mem_fun1_t<S,T,A>
           mem_fun1(S, (T::*f)(A) const);
         template<class S, class T> const_mem_fun_ref_t<S,T>
           mem_fun_ref(S, (T::*f)() const);
         template<class S, class T, class A>
           const_mem_fun1_ref_t<S,T,A>
           mem_fun1_ref(S, (T::*f)(A) const);
    
    
    
    DESCRIPTION
         The mem_fun_group of templates encapsulates a pointer  to  a
         member   function.   Each  category  of  template  (mem_fun,
         mem_fun1, mem_fun_ref,  or  mem_fun1_ref)  includes  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. A set of class templates for const
         member functions exists, each with const_ prepended  to  the
         name.
    
         The class's constructor takes a pointer to  a  member  func-
         tion,  and  uses  an  operator() to forward 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 includes zero and one argument adaptors for con-
         tainers  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) const;
         };
    
         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) const;
         };
    
         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) const;
         };
    
         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) const;
         };
         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));
    
         // For const member functions
    
         template <class S, class T> class const_mem_fun_t
                   : public unary_function<T*, S> {
            public:
              explicit const_mem_fun_t(S (T::*p)() const);
              S operator()(T* p) const;
         };
    
         template <class S, class T, class A> class const_mem_fun1_t
                   : public binary_function<T*, A, S> {
            public:
              explicit const_mem_fun1_t(S (T::*p)(A) const);
              S operator()(T* p, A x) const;
         };
    
         template<class S, class T> const_mem_fun_t<S,T>
           mem_fun(S, (T::*f)() const);
    
         template<class S, class T, class A> const_mem_fun1_t<S,T,A>
            mem_fun1(S, (T::*f)(A) const);
    
         template <class S, class T> class const_mem_fun_ref_t
                   : public unary_function<T, S> {
            public:
              explicit const_mem_fun_ref_t(S (T::*p)() const);
              S operator()(T* p) const;
         };
    
         template <class S, class T, class A>
                  class const_mem_fun1_ref_t
                   : public binary_function<T, A, S> {
            public:
              explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
              S operator()(T* p, A x) const;
         };
         template<class S, class T> const_mem_fun_ref_t<S,T>
             mem_fun_ref(S, (T::*f)() const);
         template<class S, class T, class A>
             const_mem_fun1_ref_t<S,T,A>
             mem_fun1_ref(S, (T::*f)(A) const);
    
    EXAMPLE
         //
         // mem_fun example
         //
    
         #include <functional>
         #include <list>
         using namespace std;
    
         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
    
    
    
    


    Поиск по тексту MAN-ов: 




    Партнёры:
    PostgresPro
    Inferno Solutions
    Hosting by Hoster.ru
    Хостинг:

    Закладки на сайте
    Проследить за страницей
    Created 1996-2024 by Maxim Chirkov
    Добавить, Поддержать, Вебмастеру