hmbdc
simplify-high-performance-messaging-programming
Typed.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 
4 namespace hmbdc {
5 template <char const NAME[], typename T>
6 struct Typed {
7  Typed(){}
8  explicit Typed(T v)
9  : v_(v){}
10 
11  explicit operator T() {
12  return v_;
13  }
14 
15  bool operator < (Typed t) const { return v_ < t.v_;}
16  bool operator > (Typed t) const { return v_ > t.v_;}
17  bool operator <= (Typed t) const { return v_ <= t.v_;}
18  bool operator >= (Typed t) const { return v_ >= t.v_;}
19  bool operator == (Typed t) const { return v_ == t.v_;}
20 
21  Typed operator+(Typed t) const {return Typed(v_ + t.v_);}
22  Typed operator-(Typed t) const {return Typed(v_ - t.v_);}
23  Typed operator*(Typed t) const {return Typed(v_ * t.v_);}
24  Typed operator/(Typed t) const {return Typed(v_ / t.v_);}
25 
26  Typed& operator+=(Typed t) {v_ += t.v_; return *this;}
27  Typed& operator-=(Typed t) {v_ -= t.v_; return *this;}
28  Typed& operator*=(Typed t) {v_ *= t.v_; return *this;}
29  Typed& operator/=(Typed t) {v_ /= t.v_; return *this;}
30 
31 private:
32  T v_;
33 };
34 
Definition: Base.hpp:12