C++ Atomic 库 - Flag
描述
它是无锁布尔原子类型。
声明
以下是 std::atomic_flag 的声明。
class atomic_flag;
参数
none
返回值
none
异常
none
示例
在下面的 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 ....................

