hmbdc
simplify-high-performance-messaging-programming
hmbdc
Typed.hpp
1
#include "hmbdc/Copyright.hpp"
2
#pragma once
3
#include <iostream>
4
5
namespace
hmbdc
{
6
template
<
char
const NAME[],
typename
T>
7
struct
Typed
{
8
Typed
(){}
9
10
static
constexpr
char
const
* typeName() {
return
NAME; }
11
12
explicit
Typed
(T v)
13
: v_(v){}
14
15
explicit
operator
T() {
16
return
v_;
17
}
18
19
bool
operator < (
Typed
t)
const
{
return
v_ < t.v_;}
20
bool
operator > (
Typed
t)
const
{
return
v_ > t.v_;}
21
bool
operator <= (
Typed
t)
const
{
return
v_ <= t.v_;}
22
bool
operator >= (
Typed
t)
const
{
return
v_ >= t.v_;}
23
bool
operator == (
Typed
t)
const
{
return
v_ == t.v_;}
24
25
Typed
operator+(
Typed
t)
const
{
return
Typed
(v_ + t.v_);}
26
Typed
operator-(
Typed
t)
const
{
return
Typed
(v_ - t.v_);}
27
Typed
operator*(
Typed
t)
const
{
return
Typed
(v_ * t.v_);}
28
Typed
operator/(
Typed
t)
const
{
return
Typed
(v_ / t.v_);}
29
30
Typed
& operator+=(
Typed
t) {v_ += t.v_;
return
*
this
;}
31
Typed
& operator-=(
Typed
t) {v_ -= t.v_;
return
*
this
;}
32
Typed
& operator*=(
Typed
t) {v_ *= t.v_;
return
*
this
;}
33
Typed
& operator/=(
Typed
t) {v_ /= t.v_;
return
*
this
;}
34
35
friend
36
std::ostream& operator << (std::ostream& os,
Typed
const
& t) {
37
return
os << t.v_;
38
}
39
friend
40
std::istream& operator >> (std::istream& is,
Typed
& t) {
41
return
is >> t.v_;
42
}
43
private
:
44
T v_;
45
};
46
}
47
48
hmbdc::Typed
Definition:
Typed.hpp:7
hmbdc
Definition:
Base.hpp:12
Generated by
1.8.14