nahrad TRUE za CTRUE, ked chces skontrolovat ci sa nahodou neporovnava nejaky pseudo-boolovy int s nazvom BOOL s TRUE(1), pricom hodnota by nebola 1.. //////////////////////////////// // in case of template functions, your specialization will be typeof(TRUE), which is CTRUE // however it should work, because CTRUE behaves kind of like bool // template_func(TYPE t); BOOL *b = &t; // conversion is not implicit // - force conversion, but do that only for testing class CTRUE { public: int b; CTRUE() { b = 1; } operator bool() { return (b!=0); } operator int() { return b; } operator long() { return (int)b; } int* operator &() { return &b; } // for templates to behave like BOOL void operator =(const int& a) { b = a; } void operator =(const bool& a) { b = (a ? 1 : 0); } }; typedef unsigned int uint; static bool operator ==(const int& a, const CTRUE& b); static bool operator ==(const CTRUE& a, const CTRUE& b) { return a.b == b; } static bool operator ==(const uint& a, const CTRUE& b) { return (int)a == b; } static bool operator ==(const long& a, const CTRUE& b) { return (int)a == b; } static bool operator ==(volatile const int& a, const CTRUE& b) { return (int)a == b; } static bool operator !=(const int& a, const CTRUE& b) { return !(a == b); } static bool operator !=(const CTRUE& a, const CTRUE& b) { return !(a == b); } static bool operator !=(const uint& a, const CTRUE& b) { return !((int)a == b); } static bool operator !=(const long& a, const CTRUE& b) { return !((int)a == b); } static bool operator ==(const int& a, const CTRUE& b) { if (a == 0 || a == 1) return (a!=0); __asm int 3; // now you are fucked! return 0; } #undef TRUE #define TRUE CTRUE() //////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// CBOOL nakoniec isiel skompilovat ako nahrada, ibaze sa stale bil s windowsackou hlavickou, takze to neslo skompilovat :/ //////////////////// // switch here, if you want to test it //#define BOOL_IS_CLASS #ifdef BOOL_IS_CLASS class CBOOL { public: int m_i; CBOOL() { } CBOOL(int i) { this->m_i = i; } CBOOL(unsigned int i) { this->m_i = (int)i; } CBOOL(long i) { this->m_i = i; } CBOOL(unsigned long i) { this->m_i = (int)i; } CBOOL(bool b) { this->m_i = (b ? 1 : 0); } //bool(POSITION pos) { this->m_i = (int)pos; } bool operator !=(const CBOOL& b) const { return !(*this == b); } bool operator !=(const bool& b) const { return !(*this == b); } bool operator !=(const int& b) const { return !(*this == b); } bool operator ==(const CBOOL& b) const { return (*this) == b.m_i; } bool operator ==(const bool& b) const { return (m_i && b); } bool operator ==(const int& b) const { if (b == 0 || b == 1) return (m_i == b); __asm int 3; // now you are fucked! return 0; } const CBOOL& operator =(const CBOOL& b) { m_i = b.m_i; return *this; } bool operator !() const { return !m_i; } bool operator ()() const { return m_i!=0; } operator void*() const { return (void*)m_i; } operator bool() const { return (bool)(m_i!=0); } operator long() const { return (long)m_i; } operator int() const { return (int)m_i; } operator unsigned int() const { return (unsigned int)m_i; } operator char() const { return (char)m_i; } operator unsigned char() const { return (unsigned char)m_i; } bool operator ||(const CBOOL& b) const { return m_i || b.m_i; } bool operator ||(const bool& b) const { return m_i || b; } bool operator ||(const int& b) const { return m_i || b; } bool operator &&(const CBOOL& b) const { return m_i && b.m_i; } bool operator &&(const DWORD& b) const { return m_i && b; } bool operator &&(const bool& b) const { return m_i && b; } bool operator &&(const int& b) const { return m_i && b; } bool operator &&(void *p) const { return m_i && (p!=0); } // boh ta zehnaj ak toto odkomentujes!!!!!!! (joking) // void operator |=(const int& b) { m_i |= b; } // void operator &=(const int& b) { m_i &= b; } }; static bool operator !=(const int& i, const CBOOL& b) { return !(b == i); } typedef CBOOL BOOL; #else // !BOOL_IS_CLASS typedef int BOOL; #endif