共用方式為


function::operator()

呼叫可呼叫的物件。

result_type operator()(T1 t1, T2 t2, ..., TN tN);

參數

  • TN
    第 n 個呼叫引數的型別。

  • tN
    第 n 個呼叫引數。

備註

成員函式傳回 INVOKE(fn, t1, t2, ..., tN, Ret), fn 是 *this儲存的目標物件。 您會用它來呼叫包裝的可呼叫的物件。

範例

 

// std_tr1__functional__function_operator_call.cpp 
// compile with: /EHsc 
#include <functional> 
#include <iostream> 
 
int neg(int val) 
    { 
    return (-val); 
    } 
 
int main() 
    { 
    std::function<int (int)> fn1(neg); 
    std::cout << std::boolalpha << "empty == " << !fn1 << std::endl; 
    std::cout << "val == " << fn1(3) << std::endl; 
 
    return (0); 
    } 
 
  

需求

標題: <functional>

命名空間: std

請參閱

參考

function Class

function::target