This repository has been archived by the owner on Apr 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bigcub.h++
145 lines (109 loc) · 4.57 KB
/
bigcub.h++
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// bigcub.hpp
// bigcub
//
// Created by Andy Pilate on 19/01/15.
// Copyright (c) 2015 Andy Pilate. All rights reserved.
//
//
#ifndef bigcub_h
#define bigcub_h
#include <vector>
#include <string>
#include <ostream>
#include "vmanip.h++"
#pragma GCC visibility push(default)
class BigCub {
public:
using Type = vmanip::Type;
using size_type = Type::size_type;
template<typename T>
using IntOnly = typename std::enable_if<std::is_integral<T>::value>::type;
// Constructors
BigCub() = default;
BigCub(BigCub const &n) = default;
BigCub(BigCub &&n) = default;
BigCub(Type const &n);
BigCub(Type &&n);
BigCub(char const* const str);
BigCub(std::string const &str);
template<typename T, typename = IntOnly<T>>
BigCub(T const &n);
// Destructor
~BigCub();
// Internal data access related operators and functions
Type::reference operator[](size_type n);
Type::const_reference operator[](size_type n) const;
Type::reference at(size_type n);
Type::const_reference at(size_type n) const;
Type &operator*();
Type const &operator*() const;
size_type size() const;
void compress();
// Assignation operators
BigCub &operator=(BigCub const &n) = default;
BigCub &operator=(BigCub &&n) = default;
BigCub &operator+=(BigCub const &n);
BigCub &operator-=(BigCub const &n);
BigCub &operator*=(BigCub const &n);
BigCub &operator&=(BigCub const &n);
BigCub &operator|=(BigCub const &n);
BigCub &operator^=(BigCub const &n);
BigCub &operator<<=(size_type const n);
BigCub &operator>>=(size_type const n);
// Arithmetic operators
BigCub operator+(BigCub const &n) const;
BigCub operator-(BigCub const &n) const;
BigCub operator*(BigCub const &n) const;
BigCub operator-() const;
BigCub &operator++();
BigCub operator++(int);
BigCub &operator--();
BigCub operator--(int);
// Comparaison operators
bool operator==(BigCub const &n) const;
bool operator!=(BigCub const &n) const;
bool operator<(BigCub const &n) const;
bool operator>(BigCub const &n) const;
bool operator<=(BigCub const &n) const;
bool operator>=(BigCub const &n) const;
// Bitwise operators
BigCub operator&(BigCub const &n) const;
BigCub operator|(BigCub const &n) const;
BigCub operator^(BigCub const &n) const;
BigCub operator<<(size_type const n) const;
BigCub operator>>(size_type const n) const;
BigCub operator~() const;
// Templated assignation operators
template<typename T, typename = IntOnly<T>> BigCub &operator=(T const &n);
template<typename T, typename = IntOnly<T>> BigCub &operator+=(T const &n);
template<typename T, typename = IntOnly<T>> BigCub &operator-=(T const &n);
template<typename T, typename = IntOnly<T>> BigCub &operator*=(T const &n);
template<typename T, typename = IntOnly<T>> BigCub &operator&=(T const &n);
template<typename T, typename = IntOnly<T>> BigCub &operator|=(T const &n);
template<typename T, typename = IntOnly<T>> BigCub &operator^=(T const &n);
// Templated arithmetic operators
template<typename T, typename = IntOnly<T>> BigCub operator+(T const &n) const;
template<typename T, typename = IntOnly<T>> BigCub operator-(T const &n) const;
template<typename T, typename = IntOnly<T>> BigCub operator*(T const &n) const;
// Templated comparaison operators
template<typename T, typename = IntOnly<T>> bool operator==(T const &n) const;
template<typename T, typename = IntOnly<T>> bool operator!=(T const &n) const;
template<typename T, typename = IntOnly<T>> bool operator<(T const &n) const;
template<typename T, typename = IntOnly<T>> bool operator>(T const &n) const;
template<typename T, typename = IntOnly<T>> bool operator<=(T const &n) const;
template<typename T, typename = IntOnly<T>> bool operator>=(T const &n) const;
// Templated bitwise operators
template<typename T, typename = IntOnly<T>> BigCub operator&(T const &n) const;
template<typename T, typename = IntOnly<T>> BigCub operator|(T const &n) const;
template<typename T, typename = IntOnly<T>> BigCub operator^(T const &n) const;
// Templated cast operator
template<typename T, typename = IntOnly<T>> explicit operator T() const;
protected:
Type data;
};
// std::cout overload
std::ostream &operator<<(std::ostream &o, BigCub const &n);
#include "bigcub.t.h++" // Template functions implementation
#pragma GCC visibility pop
#endif