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

📄 controlw.h

📁 科学和工程计算中使用统计功能开发工具包  
💻 H
字号:
//$$ controlw.h                Control word class

#ifndef CONTROL_WORD_LIB
#define CONTROL_WORD_LIB 0

// for organising an int as a series of bits which indicate whether an
// option is on or off.

class ControlWord
{
protected:
   int cw;                                      // the control word
public:
   ControlWord() : cw(0) {}                     // do nothing
   ControlWord(int i) : cw(i) {}                // load an integer

      // select specific bits (for testing at least one set)
   ControlWord operator*(const ControlWord& i) const { return cw & i.cw; }
   void operator*=(const ControlWord& i)  { cw &= i.cw; }

      // set bits
   ControlWord operator+(const ControlWord& i) const { return cw | i.cw; }
   void operator+=(const ControlWord& i)  { cw |= i.cw; }

      // reset bits
   ControlWord operator-(const ControlWord& i) const
      { return cw - (cw & i.cw); }
   void operator-=(const ControlWord& i) { cw -= (cw & i.cw); }

      // check if all of selected bits set or reset
   Boolean operator>=(const ControlWord& i) const { return (cw & i.cw) == i.cw; }
   Boolean operator<=(const ControlWord& i) const { return (cw & i.cw) == cw; }

      // flip selected bits
   ControlWord operator^(const ControlWord& i) const { return cw ^ i.cw; }
   ControlWord operator~() const { return ~cw; }

      // convert to integer
   int operator+() const { return cw; }
   int operator!() const { return cw==0; }
   FREE_CHECK(ControlWord)
};


#endif

⌨️ 快捷键说明

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