File: operators.h

package info (click to toggle)
pypy3 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,848 kB
  • sloc: python: 1,291,746; ansic: 74,281; asm: 5,187; cpp: 3,017; sh: 2,533; makefile: 544; xml: 243; lisp: 45; csh: 21; awk: 4
file content (115 lines) | stat: -rw-r--r-- 3,822 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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;
};

//----------------------------------------------------------------------------
class v_opeq_base {
public:
   v_opeq_base(int val);
   virtual ~v_opeq_base();

   virtual bool operator==(const v_opeq_base& other);

protected:
   int m_val;
};

class v_opeq_derived : public v_opeq_base {
public:
   v_opeq_derived(int val);
   virtual ~v_opeq_derived();

   virtual bool operator==(const v_opeq_derived& other);
};