/* ccsdu2004@yahoo.com.cn www.gaimo.net 02.15.2009 */ //dev c++ //boost operators. #include <cstdlib> #include <iostream> #include <boost/operators.hpp> using namespace std; using namespace boost; //less_tahn_comparable //equality_comparable //addable //subtractable //rable for | and |= //andable & and &= //incrementable ++ //decrementable -- //equivalent < ad == //dereferenceable -> and * //indexable [] //totally_ordered //additve //... class some_class: equivalent<some_class> { public: some_class(int _value): value(_value){} bool less_than(const some_class & other)const { return value < other.value; } private: int value; }; bool operator< (const some_class &lhs, const some_class &rhs) { return lhs.less_than(rhs); } int main(int argc, char *argv[]) { some_class s1(1); some_class s2(-1); if(s1==s2) cout<<"s1==s2"<<endl; else cout<<"s1!=s2"<<endl; system("PAUSE"); return EXIT_SUCCESS; } this instance come from beyond the c++ sl an introduction to booooooost