⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atomicbool.h

📁 遗传算法的一个库
💻 H
字号:
#ifndef __GradSoft_AtomicBool_h#define __GradSoft_AtomicBool_h /* * part of GradSoft Threading ToolBox * (C) GradSoft, 2000, 2001 * $Id: AtomicBool.h,v 1.7 2001/12/26 09:00:08 kav Exp $ */#ifndef __GradSoft_ThreadingPostConfig_h#include <GradSoft/ThreadingPostConfig.h>#endifnamespace GradSoft {/** * boolean value with atomic getting/setting. **/class AtomicBool{private:  // one byte usially atomic  unsigned char value_;public:  ///  AtomicBool() throw() :value_(0){}  ///  AtomicBool(AtomicBool& x) throw() :value_(x.value_) {}  ///  AtomicBool(bool x) throw() :value_(x) {}  ///  bool value() const throw() { return value_!=0; }  ///  bool value() volatile const throw() { return value_!=0; }  ///  operator bool() const throw() { return value_ != 0; }  ///  void value(bool x) throw() { (x==0) ? (value_=1) : (value_=0) ; }  ///  AtomicBool& operator=(const AtomicBool& x)  { value_ = x.value_; return *this; }#ifndef _MSC_VER  ///  volatile AtomicBool& operator=(const AtomicBool& x) volatile  { value_ = x.value_; return *this; }#endif  ///  AtomicBool& operator=(bool x)  { value_ = x; return *this; }  ///  volatile AtomicBool& operator=(bool x) volatile  { value_ = x; return *this; }};///inline bool operator==(const AtomicBool& x, const AtomicBool& y){  return x.value()==y.value();}///inline bool operator==(const AtomicBool& x, bool y){  return x.value()==y;}///inline bool operator==(bool x, const AtomicBool& y){  return x==y.value();}///inline bool operator!=(const AtomicBool& x, const AtomicBool& y){  return x.value()!=y.value();}///inline bool operator!=(const AtomicBool& x, bool y){  return x.value()!=y;}///inline bool operator!=(bool x, const AtomicBool& y){  return x!=y.value();}}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -