]> www.ginac.de Git - ginac.git/blobdiff - ginac/relational.cpp
A better return_type_tinfo() mechanism.
[ginac.git] / ginac / relational.cpp
index d2b3880524c04ad56ae4d4abc33ab7ffb81478fd..f3329f98824edc92dd6c3fd6739abb0b83353d0d 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of relations between expressions */
 
 /*
- *  GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(relational, basic,
 // default constructor
 //////////
 
-relational::relational() : basic(TINFO_relational) {}
+relational::relational() : basic(&relational::tinfo_static) {}
 
 //////////
 // other constructors
@@ -48,7 +48,7 @@ relational::relational() : basic(TINFO_relational) {}
 
 // public
 
-relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(TINFO_relational), lh(lhs), rh(rhs), o(oper) {}
+relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(&relational::tinfo_static), lh(lhs), rh(rhs), o(oper) {}
 
 //////////
 // archiving
@@ -250,7 +250,7 @@ unsigned relational::return_type() const
        return lh.return_type();
 }
    
-unsigned relational::return_type_tinfo() const
+return_type_t relational::return_type_tinfo() const
 {
        GINAC_ASSERT(lh.return_type_tinfo()==rh.return_type_tinfo());
        return lh.return_type_tinfo();
@@ -258,7 +258,8 @@ unsigned relational::return_type_tinfo() const
 
 unsigned relational::calchash() const
 {
-       unsigned v = golden_ratio_hash(tinfo());
+       const void* this_tinfo = (const void*)typeid(*this).name();
+       unsigned v = golden_ratio_hash((p_int)this_tinfo);
        unsigned lhash = lh.gethash();
        unsigned rhash = rh.gethash();
 
@@ -338,13 +339,13 @@ relational::operator relational::safe_bool() const
                case not_equal:
                        return make_safe_bool(!ex_to<numeric>(df).is_zero());
                case less:
-                       return make_safe_bool(ex_to<numeric>(df)<_num0);
+                       return make_safe_bool(ex_to<numeric>(df)<(*_num0_p));
                case less_or_equal:
-                       return make_safe_bool(ex_to<numeric>(df)<=_num0);
+                       return make_safe_bool(ex_to<numeric>(df)<=(*_num0_p));
                case greater:
-                       return make_safe_bool(ex_to<numeric>(df)>_num0);
+                       return make_safe_bool(ex_to<numeric>(df)>(*_num0_p));
                case greater_or_equal:
-                       return make_safe_bool(ex_to<numeric>(df)>=_num0);
+                       return make_safe_bool(ex_to<numeric>(df)>=(*_num0_p));
                default:
                        throw(std::logic_error("invalid relational operator"));
        }