C++ 原子庫 - 獲取異或



描述

它用與非原子引數進行邏輯異或的結果替換原子物件,並獲取原子的前一個值。

宣告

以下是 std::atomic_fetch_xor 的宣告。

template< class Integral >
Integral atomic_fetch_xor( volatile std::atomic<Integral>* obj, Integral arg );

C++11

template< class Integral >
Integral atomic_fetch_xor( std::atomic<Integral>* obj, Integral arg );

以下是 std::atomic_fetch_xor_explicit 的宣告。

template< class Integral >
Integral atomic_fetch_xor_explicit( std::atomic<Integral>* obj, Integral arg, 
                                    std::memory_order order );

C++11

template< class Integral >
Integral atomic_fetch_xor_explicit( volatile std::atomic<Integral>* obj, Integral arg, 
                                    std::memory_order order );

引數

  • obj − 用於指向要修改的原子物件。

  • desr − 用於儲存原子物件中的值。

  • order − 用於同步此操作的記憶體排序。

返回值

它返回在 *obj 的修改順序中此函式效果之前的立即值。

異常

無異常 − 此成員函式從不丟擲異常。

atomic.htm
廣告
© . All rights reserved.