tiny_int1.hh
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
- #ifndef __tiny_int1_hh__
- #define __tiny_int1_hh__
- class tiny_int {
- char value;
- public:
- tiny_int() {}
- tiny_int(short int v) : value(v) {}
- operator short int() const {return (short int)value;};
- tiny_int &operator = (short int v) {value=v; return *this;}
- tiny_int &operator += (short int v) {value+=v; return *this;}
- tiny_int &operator -= (short int v) {value-=v; return *this;}
- tiny_int &operator *= (short int v) {value*=v; return *this;}
- tiny_int &operator /= (short int v) {value/=v; return *this;}
- tiny_int &operator %= (short int v) {value%=v; return *this;}
- tiny_int &operator &= (short int v) {value&=v; return *this;}
- tiny_int &operator |= (short int v) {value|=v; return *this;}
- tiny_int &operator ^= (short int v) {value^=v; return *this;}
- tiny_int &operator <<= (short int v) {value<<=v; return *this;}
- tiny_int &operator >>= (short int v) {value>>=v; return *this;}
- tiny_int &operator ++ () {value++; return *this;}
- tiny_int &operator -- () {value--; return *this;}
- tiny_int operator ++ (int) {tiny_int tmp=value; value++; return tmp;}
- tiny_int operator -- (int) {tiny_int tmp=value; value--; return tmp;}
- tiny_int operator - (const tiny_int& i) const {return value - i;}
- tiny_int operator + (const tiny_int& i) const {return value + i;}
- tiny_int operator * (const tiny_int& i) const {return value * i;}
- tiny_int operator / (const tiny_int& i) const {return value / i;}
- tiny_int operator % (const tiny_int& i) const {return value % i;}
- tiny_int operator | (const tiny_int& i) const {return value | i;}
- tiny_int operator & (const tiny_int& i) const {return value & i;}
- tiny_int operator ^ (const tiny_int& i) const {return value ^ i;}
- tiny_int operator << (const tiny_int& i) const {return value << i;}
- tiny_int operator >> (const tiny_int& i) const {return value >> i;}
- };
- #endif