pypy / pypy / module / cppyy / test / operators.h

class number  {
public:
   number() { m_int = 0; }
   number(int i) { m_int = i; }

   number operator+(const number& n) const { return number(m_int + n.m_int); }
   number operator+(int n) const { return number(m_int + n); }
   number operator-(const number& n) const { return number(m_int - n.m_int); }
   number operator-(int n) const { return number(m_int - n); }
   number operator*(const number& n) const { return number(m_int * n.m_int); }
   number operator*(int n) const { return number(m_int * n); }
   number operator/(const number& n) const { return number(m_int / n.m_int); }
   number operator/(int n) const { return number(m_int / n); }
   number operator%(const number& n) const { return number(m_int % n.m_int); }
   number operator%(int n) const { return number(m_int % n); }

   number& operator+=(const number& n) { m_int += n.m_int; return *this; }
   number& operator-=(const number& n) { m_int -= n.m_int; return *this; }
   number& operator*=(const number& n) { m_int *= n.m_int; return *this; }
   number& operator/=(const number& n) { m_int /= n.m_int; return *this; }
   number& operator%=(const number& n) { m_int %= n.m_int; return *this; }

   number operator-() { return number( -m_int ); }

   bool operator<(const number& n) const { return m_int < n.m_int; }
   bool operator>(const number& n) const { return m_int > n.m_int; }
   bool operator<=(const number& n) const { return m_int <= n.m_int; }
   bool operator>=(const number& n) const { return m_int >= n.m_int; }
   bool operator!=(const number& n) const { return m_int != n.m_int; }
   bool operator==(const number& n) const { return m_int == n.m_int; }

   operator bool() { return m_int != 0; }

   number operator&(const number& n) const { return number(m_int & n.m_int); }
   number operator|(const number& n) const { return number(m_int | n.m_int); }
   number operator^(const number& n) const { return number(m_int ^ n.m_int); }

   number& operator&=(const number& n) { m_int &= n.m_int; return *this; }
   number& operator|=(const number& n) { m_int |= n.m_int; return *this; }
   number& operator^=(const number& n) { m_int ^= n.m_int; return *this; }

   number operator<<(int i) const { return number(m_int << i); }
   number operator>>(int i) const { return number(m_int >> i); }

private:
   int m_int;
};

//----------------------------------------------------------------------------
struct operator_char_star {       // for testing user-defined implicit casts
   operator_char_star() : m_str((char*)"operator_char_star") {}
   operator char*() { return m_str; }
   char* m_str;
};

struct operator_const_char_star {
   operator_const_char_star() : m_str("operator_const_char_star" ) {}
   operator const char*() { return m_str; }
   const char* m_str;
};

struct operator_int {
   operator int() { return m_int; }
   int m_int;
};

struct operator_long {
   operator long() { return m_long; }
   long m_long;
};

struct operator_double {
   operator double() { return m_double; }
   double m_double;
};

struct operator_short {
   operator short() { return m_short; }
   unsigned short m_short;
};

struct operator_unsigned_int {
   operator unsigned int() { return m_uint; }
   unsigned int m_uint;
};

struct operator_unsigned_long {
   operator unsigned long() { return m_ulong; }
   unsigned long m_ulong;
};

struct operator_float {
   operator float() { return m_float; }
   float m_float;
};
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.