Develop Biology
The language of life
StrongTypedef.h
Go to the documentation of this file.
1
/*
2
* This file is a part of the Biology project by eons LLC.
3
* Biology (aka Develop Biology) is a framework for approaching software
4
* development from a natural sciences perspective.
5
*
6
* Copyright (C) 2021 Séon O'Shannon & eons LLC
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as
10
* published by the Free Software Foundation, either version 3 of the
11
* License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*/
21
22
#pragma once
23
24
//since we use these here, we might as well include them.
25
#include <ostream>
26
37
#define BIO_STRONG_TYPEDEF(type, name, defaultValue) \
38
class name \
39
{ \
40
public: \
41
name(type t = defaultValue) : \
42
m_t(t) \
43
{} \
44
~name() {} \
45
operator type() {return m_t;} \
46
bool operator==(const type& t) const {return m_t == t;} \
47
bool operator!=(const type& t) const {return m_t != t;} \
48
bool operator<=(const type& t) const {return m_t <= t;} \
49
bool operator>=(const type& t) const {return m_t >= t;} \
50
bool operator<(const type& t) const {return m_t < t;} \
51
bool operator>(const type& t) const {return m_t > t;} \
52
bool operator==(const name& other) const {return m_t == other.m_t;} \
53
bool operator!=(const name& other) const {return m_t != other.m_t;} \
54
bool operator<=(const name& other) const {return m_t <= other.m_t;} \
55
bool operator>=(const name& other) const {return m_t >= other.m_t;} \
56
bool operator<(const name& other) const {return m_t < other.m_t;} \
57
bool operator>(const name& other) const {return m_t > other.m_t;} \
58
type& operator++() {return ++m_t;} \
59
type operator++(int) {return m_t++;} \
60
type& operator--() {return --m_t;} \
61
type operator--(int) {return m_t--;} \
62
type operator+=(const type& t) {return m_t += t;} \
63
type operator-=(const type& t) {return m_t -= t;} \
64
type operator+=(const name& other) {return m_t += other.m_t;} \
65
type operator-=(const name& other) {return m_t -= other.m_t;} \
66
type operator+(const type& t) const {return m_t + t;} \
67
type operator-(const type& t) const {return m_t - t;} \
68
type operator+(const name& other) const {return m_t + other.m_t;} \
69
type operator-(const name& other) const {return m_t - other.m_t;} \
70
type operator*=(const type& t) {return m_t *= t;} \
71
type operator/=(const type& t) {return m_t /= t;} \
72
type operator*=(const name& other) {return m_t *= other.m_t;} \
73
type operator/=(const name& other) {return m_t /= other.m_t;} \
74
type operator*(const type& t) const {return m_t * t;} \
75
type operator/(const type& t) const {return m_t / t;} \
76
type operator*(const name& other) const {return m_t * other.m_t;} \
77
type operator/(const name& other) const {return m_t / other.m_t;} \
78
friend std::ostream& operator <<(std::ostream& out, const name& t) \
79
{ \
80
out << t.m_t; \
81
return out; \
82
} \
83
/*that's all we're doing for now. Please add to this list as necessary*/
\
84
\
85
/*public because we need to treat this as type when we don't know the type.*/
\
86
public: \
87
type m_t; \
88
};
inc
bio
common
macros
StrongTypedef.h
Generated by
1.9.4