/*
cool.hpp
"一生二,二生三,三生万物",无三不成理,这就是事物的三态性。
实例:
int a = 1;
int b = 2;
cool c;
c = compare(a, b)
sdragonx 2010-04-10 09:31:05
*/
#ifndef COOL_HPP_20100410093105
#define COOL_HPP_20100410093105
class sign_t
{
public:
sign_t():m_value(0)
{
}
sign_t(int n)
{
this->operator =(n);
}
const sign_t& operator=(int n)
{
if(!n)
m_value = 0;
else if(n<0)
m_value = -1;
else
m_value = 1;
return *this;
}
template<typename T>operator T()const
{
return T(m_value);
}
bool operator> (const int& n)const{ return m_value>n; }
bool operator>=(const int& n)const{ return m_value>=n; }
bool operator< (const int& n)const{ return m_value<n; }
bool operator<=(const int& n)const{ return m_value<=n; }
bool operator! () const{ return !m_value; }
bool operator==(const int& n)const{ return m_value==n; }
bool is_upper()const { return m_value>0; }
bool is_lower()const { return m_value<0; }
bool is_equal()const { return !m_value; }
private:
int m_value;
};
typedef sign_t cool_t, cool;
#endif //COOL_HPP_20100410093105