質問編集履歴

1

追加分

2017/11/07 14:19

投稿

kkkmokotan
kkkmokotan

スコア45

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  しかしこのプログラムを実行したところ、equal_rangeのイテレータが空になってしまいました。確かにデータは追加したはずなのですが。
4
4
 
5
+
6
+
5
- struct v比較演算子の定義によるエラかとも思いましたが、multimapへデータ追加時はError等が起こっていないので原因がわかりまん。(比較演算子関連だと追加時にもインデックス保持でエラーが起こる思います
7
+ struct v比較演算子の定義もコせます
8
+
9
+
6
10
 
7
11
 
8
12
 
@@ -41,3 +45,177 @@
41
45
 
42
46
 
43
47
  ```
48
+
49
+
50
+
51
+
52
+
53
+ 以下に構造体の定義を追記いたします。
54
+
55
+ ```C++
56
+
57
+ typedef struct v {
58
+
59
+ uint8_t first;
60
+
61
+ uint8_t second;
62
+
63
+ uint8_t third;
64
+
65
+ uint8_t fourth;
66
+
67
+ inline bool operator > (const struct v &i) const {
68
+
69
+ if (first > i.first) {
70
+
71
+ return true;
72
+
73
+ } else if(first == i.first && second > i.second){
74
+
75
+ return true;
76
+
77
+ } else if(first == i.first && second == i.second && third > i.third){
78
+
79
+ return true;
80
+
81
+ } else if(first == i.first && second == i.second && third == i.third && fourth > i.fourth){
82
+
83
+ return true;
84
+
85
+ } else {
86
+
87
+ return false;
88
+
89
+ }
90
+
91
+ }
92
+
93
+
94
+
95
+ inline bool operator >= (const struct v &i) const {
96
+
97
+ if (first >= i.first) {
98
+
99
+ return true;
100
+
101
+
102
+
103
+ } else if(first == i.first && second >= i.second){
104
+
105
+ return true;
106
+
107
+
108
+
109
+ } else if(first == i.first && second == i.second && third >= i.third){
110
+
111
+ return true;
112
+
113
+
114
+
115
+ } else if(first == i.first && second == i.second && third == i.third && fourth >= i.fourth){
116
+
117
+ return true;
118
+
119
+
120
+
121
+ } else {
122
+
123
+ return false;
124
+
125
+
126
+
127
+ }
128
+
129
+ }
130
+
131
+
132
+
133
+ inline bool operator < (const struct v &i) const {
134
+
135
+ if (first > i.first) {
136
+
137
+ return false;
138
+
139
+ } else if(first == i.first && second > i.second){
140
+
141
+ return false;
142
+
143
+ } else if(first == i.first && second == i.second && third > i.third){
144
+
145
+ return false;
146
+
147
+ } else if(first == i.first && second == i.second && third == i.third && fourth > i.fourth){
148
+
149
+ return false;
150
+
151
+ } else {
152
+
153
+ return true;
154
+
155
+ }
156
+
157
+ }
158
+
159
+
160
+
161
+ inline bool operator <= (const struct v &i) const {
162
+
163
+ if (first >= i.first) {
164
+
165
+ return false;
166
+
167
+ } else if(first == i.first && second >= i.second){
168
+
169
+ return false;
170
+
171
+ } else if(first == i.first && second == i.second && third >= i.third){
172
+
173
+ return false;
174
+
175
+ } else if(first == i.first && second == i.second && third == i.third && fourth >= i.fourth){
176
+
177
+ return false;
178
+
179
+ } else {
180
+
181
+ return true;
182
+
183
+ }
184
+
185
+ }
186
+
187
+
188
+
189
+ inline bool operator == (const struct v &i) const {
190
+
191
+ if (first == i.first && second == i.second && third == i.third && fourth == i.fourth) {
192
+
193
+ return true;
194
+
195
+ } else {
196
+
197
+ return false;
198
+
199
+ }
200
+
201
+ }
202
+
203
+
204
+
205
+ inline bool operator != (const struct v &i) const {
206
+
207
+ if (first != i.first || second != i.second || third != i.third || fourth != i.fourth) {
208
+
209
+ return true;
210
+
211
+ } else {
212
+
213
+ return false;
214
+
215
+ }
216
+
217
+ }
218
+
219
+ }
220
+
221
+ ```