類模板
<functional>

std::const_mem_fun_t

template <class S, class T> class const_mem_fun_t;
從const無參成員生成函式物件類(指標版本)
從類T的常數無參成員生成一元函式物件類,該成員返回型別為S的值。

const_mem_fun_t通常用作型別。函式 mem_fun(也在標頭檔案 <functional> 中定義)可用於直接構造該型別的物件。

該類派生自unary_function,通常定義為

1
2
3
4
5
6
7
8
9
template <class S, class T>
  class const_mem_fun_t : public unary_function <T*,S>
{
  S (T::*pmem)() const;
public:
  explicit const_mem_fun_t ( S (T::*p)() const ) : pmem (p) {}
  S operator() (T* p) const
    { return (p->*pmem)(); }
};

成員

建構函式
從類T的常數成員函式p構造一元函式物件類。該成員函式的返回型別應與型別S相容。
S operator() (T* p) const
帶一個引數的成員函式。該引數為指向型別為T的物件指標,將呼叫該物件的常數成員。

另見