头文件
''boost/operators.hpp"
operators库由多个基类组成。派生operators的基类,在派生类中实现必须要实现的重载运算符函数,可以得到基类中其他的重载函数
less_than_comparable
内含:
bool operator<(const T&,const T&);
bool operator>(const T&,const T&);
bool operator<=(const T&,const T&);
bool operator>=(const T&,const T&);
当派生自boost::less_than_comparable时,派生类必须提供如下代码:
bool operator<(const T&,const T&);
equality_comparable
内含:
bool operator==(const T&,const T&);
bool operator!=(const T&,const T&);
必须实现:
bool operator==(const T&,const T&);
addable
内含:
T operator+(const T&,const T&);
T operator+=(const T&,const T&);
必须含有:
T operator+=(const T&,const T&);
subtractable
T operator-(const T&,const T&);
T operator-=(const T&,const T&);
必须含有:
T operator-=(const T&,const T&);
orable
T operator|(const T&,const T&);
T operator|=(const T&,const T&);
必须含有:
T operator|=(const T&,const T&);
andable
T operator&(const T&,const T&);
T operator&=(const T&,const T&);
必须含有:
T operator&=(const T&,const T&);
incrementable
T& opeartor++(T&);
T opperator++(T&,int);
必须含有:
T& operator++(T&);
decrementable
T& opeartor--(T&);
T opperator--(T&,int);
必须含有:
T& operator--(T&);
equivalent
bool operator<(const T&,const T&);
bool operator==(const T&,const T&);
必须含有:
bool operator<(const T&,const T&);
dereferenceable
R* operator->() const;
R& operator*() const;
必须含有:
R operator*() const;
避免对象膨胀,采用的写法