c ++ – Define a class that behaves exactly like an `int`

This is an exercise to create a class that behaves exactly like a int.

Questions

  • Am I missing something?
  • Or did I go in the wrong way?
  • Is there anything that I could improve?
  • Are there any tips I could learn from this?
  • What about the style? is the style correct?
#understand  // std :: cost
#understand   // std :: move

class jd_int {
public:
jd_int () = default;

jd_int (int i): _i {i} {}
jd_int (const jd_int & jdi): _i {jdi._i} {}
jd_int (jd_int && jdi): _i {std :: move (jdi._i)} {}

jd_int operator = (int i) {_i = i; return * this; }
jd_int operator = (double d) {_i = d; return * this; }
operator jd_int = (const jd_int & jdi) {_i = jdi._i; return * this; }
jd_int operator = (jd_int && jdi) {_i = std :: move (jdi._i); return * this; }

~ jd_int () = default;

operator bool () {return !! _ i; }
int operator () {returns static_cast(_I); }
double operator () {return static_cast(_I); }

jd_int operator + = (jd_int jdi) {return _i + = jdi._i; }
jd_int operator + (jd_int jdi) {return _i + jdi._i; }

operator jd_int - = (jd_int jdi) {return _i - = jdi._i; }
jd_int operator- (jd_int jdi) {return _i - jdi._i; }

jd_int operator * = (jd_int jdi) {return _i * = jdi._i; }
operator jd_int * (jd_int jdi) {return _i * jdi._i; }

jd_int operator / = (jd_int jdi) {return _i / = jdi._i; }
jd_int operator / (jd_int jdi) {return _i / jdi._i; }

jd_int operator% = (jd_int jdi) {return _i% = jdi._i; }
jd_int operator% (jd_int jdi) {return _i% jdi._i; }

operator jd_int ++ () {return ++ _ i; }
operator jd_int ++ (int) {jd_int tmp = * this; ++ _ i; tmp back; }

operator jd_int - () {return --_ i; }
operator jd_int - (int) {jd_int tmp = * this; --_I; tmp back; }

friend bool operator< (jd_int lhs, jd_int rhs);
    friend bool operator> (jd_int lhs, jd_int rhs);
friend bool operator<=(jd_int lhs, jd_int rhs);
    friend bool operator>= (jd_int lhs, jd_int rhs);
friend bool operator == (jd_int lhs, jd_int rhs);
friend bool operator! = = (jd_int lhs, jd_int rhs);

private:
int _i;

friend std :: ostream & operator <<(std::ostream& os, const jd_int jdi);
    friend std::istream& operator>> (std :: istream & is, jd_int jdi);
};

Boolean operator <(jd_int lhs, jd_int rhs) {return (lhs._i <  rhs._i); }
bool operator> (jd_int lhs, jd_int rhs) {return (lhs._i> rhs._i); }
Boolean operator <= (jd_int lhs, jd_int rhs) {return (lhs._i <= rhs._i); }
bool operator>= (jd_int lhs, jd_int rhs) {return (lhs._i> = rhs._i); }
operator bool == (jd_int lhs, jd_int rhs) {return (lhs._i == rhs._i); }
bool operator! = = (jd_int lhs, jd_int rhs) {return (lhs._i! = rhs._i); }

std :: ostream & operator << (std :: ostream & os, const jd_int jdi) {
os << jdi._i;
    return os;
}

std::istream& operator>> (std :: istream & is, jd_int jdi) {
is >> jdi._i;
the return is;
}
`` `