C++ 函式庫 - 運算子



描述

它用於賦值新的目標。

宣告

以下是 function::operator= 函式的宣告:

C++11

以下函式將 other 的目標的副本賦值給 *this,就像執行 function(other) 一樣。

function& operator=( const function& other );

異常

函式移動

以下函式將 other 的目標移動到 *this。other 處於有效狀態,但值未指定。

function& operator=( function&& other );

異常

丟棄當前目標

以下函式丟棄當前目標。呼叫後,*this 為空。

function& operator=( std::nullptr_t );

異常

noexcept: noexcept 說明。

設定目標

以下函式將 *this 的目標設定為可呼叫物件 f。

template< class F >
function& operator=( F&& f );

template< class F > 
function& operator=( std::reference_wrapper f )

異常

noexcept: noexcept 說明。

引數

  • other − 用於初始化 *this 的函式物件。

  • f − 用於初始化 *this 的可呼叫物件。

functional.htm
廣告