C++ 原子庫 - 標誌



描述

它是無鎖布林原子型別。

宣告

以下是 std::atomic_flag 的宣告。

class atomic_flag;

引數

返回值

異常

示例

以下為 std::atomic_flag 的示例。

#include <iostream>       
#include <typeinfo>       
#include <exception>      

class Polymorphic {virtual void member(){}};

int main () {
   try {
      Polymorphic * pb = 0;
      typeid(*pb);  
   } catch (std::exception& e) {
      std::cerr << "exception caught: " << e.what() << '\n';
   }
   return 0;
}

示例輸出應如下所示:

Output from thread 0
Output from thread 0
Output from thread 0
Output from thread 0
Output from thread 0
Output from thread 0
Output from thread 0
....................
atomic.htm
廣告