類模板
<functional>

std::const_mem_fun1_t

template <class S, class T, class A> class const_mem_fun1_t;
從單引數的 const 成員(指標版本)生成函式物件類
T 類的常量成員生成一個二元函式物件類,該成員接受型別為 A 的引數並返回型別為 S 的值。

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

此類派生自 binary_function,通常定義為

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

成員

建構函式
從類 T 的常量成員函式 p 構建一個二元函式物件類。此成員函式的返回型別應與型別 S 型別相容。
S operator() (T* p, A x)
接受兩個引數的成員函式:p 是一個指向型別為 T 的物件的指標,其常量成員將使用 x 作為引數呼叫。

另見