共用方式為


pointer_to_unary_function 類別

將一元函式指標轉換成可調適性一元函式。 在 C++11 中已被取代,在 C++17 中移除。

語法

template <class Arg, class Result>
class pointer_to_unary_function
    : public unary_function<Arg, Result>
{
    explicit pointer_to_unary_function(Result(*pfunc)(Arg));
    Result operator()(Arg left) const;
};

參數

pfunc
要轉換的二元函式。

left
呼叫 *pfunc 的物件

傳回值

類別範本會儲存 的 pfunc 複本。 它會將其成員函 operator() 式定義為傳回 (* pfunc )(_ Left )。

備註

一元函式指標是函式物件,可傳遞至需要一元函式當作參數的任何 C++ 標準程式庫演算法,但它不具可調適性。 若要將它與配接器搭配使用,例如將值系結至該配接器,或將其與否定器搭配使用,則必須提供巢狀類型 argument_type ,才能 result_type 進行這類調整。 透過 pointer_to_unary_function 的轉換可讓函式配接器使用二元函式指標。

範例

pointer_to_unary_function 的建構函式很少會直接使用。 如需如何宣告並使用 pointer_to_unary_function 配接器述詞的範例,請參閱協助程式函式 ptr_fun