Mercurial > hg > octave-lyh
annotate liboctave/oct-inttypes.h @ 7534:ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2008 17:37:37 -0500 |
parents | 6f10bbb2854a |
children | 6929e40fc597 |
rev | line source |
---|---|
4902 | 1 /* |
2 | |
7017 | 3 Copyright (C) 2004, 2005, 2006, 2007 John W. Eaton |
4902 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
4902 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
4902 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_inttypes_h) | |
24 #define octave_inttypes_h 1 | |
25 | |
6482 | 26 #include <climits> |
27 | |
4902 | 28 #include <limits> |
29 #include <iostream> | |
30 | |
5828 | 31 #include "oct-types.h" |
4953 | 32 #include "lo-ieee.h" |
4969 | 33 #include "lo-mappers.h" |
4902 | 34 |
35 template <class T1, class T2> | |
36 class | |
37 octave_int_binop_traits | |
38 { | |
39 public: | |
40 // The return type for a T1 by T2 binary operation. | |
41 typedef T1 TR; | |
42 }; | |
43 | |
44 #define OCTAVE_INT_BINOP_TRAIT(T1, T2, T3) \ | |
45 template<> \ | |
46 class octave_int_binop_traits <T1, T2> \ | |
47 { \ | |
48 public: \ | |
49 typedef T3 TR; \ | |
50 } | |
51 | |
5828 | 52 OCTAVE_INT_BINOP_TRAIT (int8_t, int8_t, int8_t); |
53 OCTAVE_INT_BINOP_TRAIT (int8_t, int16_t, int8_t); | |
54 OCTAVE_INT_BINOP_TRAIT (int8_t, int32_t, int8_t); | |
55 OCTAVE_INT_BINOP_TRAIT (int8_t, int64_t, int8_t); | |
56 OCTAVE_INT_BINOP_TRAIT (int8_t, uint8_t, int8_t); | |
57 OCTAVE_INT_BINOP_TRAIT (int8_t, uint16_t, int8_t); | |
58 OCTAVE_INT_BINOP_TRAIT (int8_t, uint32_t, int8_t); | |
59 OCTAVE_INT_BINOP_TRAIT (int8_t, uint64_t, int8_t); | |
4902 | 60 |
5828 | 61 OCTAVE_INT_BINOP_TRAIT (int16_t, int8_t, int16_t); |
62 OCTAVE_INT_BINOP_TRAIT (int16_t, int16_t, int16_t); | |
63 OCTAVE_INT_BINOP_TRAIT (int16_t, int32_t, int16_t); | |
64 OCTAVE_INT_BINOP_TRAIT (int16_t, int64_t, int16_t); | |
65 OCTAVE_INT_BINOP_TRAIT (int16_t, uint8_t, int16_t); | |
66 OCTAVE_INT_BINOP_TRAIT (int16_t, uint16_t, int16_t); | |
67 OCTAVE_INT_BINOP_TRAIT (int16_t, uint32_t, int16_t); | |
68 OCTAVE_INT_BINOP_TRAIT (int16_t, uint64_t, int16_t); | |
4902 | 69 |
5828 | 70 OCTAVE_INT_BINOP_TRAIT (int32_t, int8_t, int32_t); |
71 OCTAVE_INT_BINOP_TRAIT (int32_t, int16_t, int32_t); | |
72 OCTAVE_INT_BINOP_TRAIT (int32_t, int32_t, int32_t); | |
73 OCTAVE_INT_BINOP_TRAIT (int32_t, int64_t, int32_t); | |
74 OCTAVE_INT_BINOP_TRAIT (int32_t, uint8_t, int32_t); | |
75 OCTAVE_INT_BINOP_TRAIT (int32_t, uint16_t, int32_t); | |
76 OCTAVE_INT_BINOP_TRAIT (int32_t, uint32_t, int32_t); | |
77 OCTAVE_INT_BINOP_TRAIT (int32_t, uint64_t, int32_t); | |
4902 | 78 |
5828 | 79 OCTAVE_INT_BINOP_TRAIT (int64_t, int8_t, int64_t); |
80 OCTAVE_INT_BINOP_TRAIT (int64_t, int16_t, int64_t); | |
81 OCTAVE_INT_BINOP_TRAIT (int64_t, int32_t, int64_t); | |
82 OCTAVE_INT_BINOP_TRAIT (int64_t, int64_t, int64_t); | |
83 OCTAVE_INT_BINOP_TRAIT (int64_t, uint8_t, int64_t); | |
84 OCTAVE_INT_BINOP_TRAIT (int64_t, uint16_t, int64_t); | |
85 OCTAVE_INT_BINOP_TRAIT (int64_t, uint32_t, int64_t); | |
86 OCTAVE_INT_BINOP_TRAIT (int64_t, uint64_t, int64_t); | |
4902 | 87 |
5828 | 88 OCTAVE_INT_BINOP_TRAIT (uint8_t, int8_t, int8_t); |
89 OCTAVE_INT_BINOP_TRAIT (uint8_t, int16_t, int8_t); | |
90 OCTAVE_INT_BINOP_TRAIT (uint8_t, int32_t, int8_t); | |
91 OCTAVE_INT_BINOP_TRAIT (uint8_t, int64_t, int8_t); | |
92 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint8_t, uint8_t); | |
93 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint16_t, uint8_t); | |
94 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint32_t, uint8_t); | |
95 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint64_t, uint8_t); | |
4902 | 96 |
5828 | 97 OCTAVE_INT_BINOP_TRAIT (uint16_t, int8_t, int16_t); |
98 OCTAVE_INT_BINOP_TRAIT (uint16_t, int16_t, int16_t); | |
99 OCTAVE_INT_BINOP_TRAIT (uint16_t, int32_t, int16_t); | |
100 OCTAVE_INT_BINOP_TRAIT (uint16_t, int64_t, int16_t); | |
101 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint8_t, uint16_t); | |
102 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint16_t, uint16_t); | |
103 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint32_t, uint16_t); | |
104 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint64_t, uint16_t); | |
4902 | 105 |
5828 | 106 OCTAVE_INT_BINOP_TRAIT (uint32_t, int8_t, int32_t); |
107 OCTAVE_INT_BINOP_TRAIT (uint32_t, int16_t, int32_t); | |
108 OCTAVE_INT_BINOP_TRAIT (uint32_t, int32_t, int32_t); | |
109 OCTAVE_INT_BINOP_TRAIT (uint32_t, int64_t, int32_t); | |
110 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint8_t, uint32_t); | |
111 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint16_t, uint32_t); | |
112 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint32_t, uint32_t); | |
113 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint64_t, uint32_t); | |
4902 | 114 |
5828 | 115 OCTAVE_INT_BINOP_TRAIT (uint64_t, int8_t, int64_t); |
116 OCTAVE_INT_BINOP_TRAIT (uint64_t, int16_t, int64_t); | |
117 OCTAVE_INT_BINOP_TRAIT (uint64_t, int32_t, int64_t); | |
118 OCTAVE_INT_BINOP_TRAIT (uint64_t, int64_t, int64_t); | |
119 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint8_t, uint64_t); | |
120 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint16_t, uint64_t); | |
121 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint32_t, uint64_t); | |
122 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint64_t, uint64_t); | |
4902 | 123 |
124 template <class T1, class T2> | |
125 inline T2 | |
126 octave_int_fit_to_range (const T1& x, const T2& mn, const T2& mx) | |
127 { | |
4963 | 128 return (x > mx ? mx : (x < mn ? mn : T2 (x))); |
4902 | 129 } |
130 | |
4943 | 131 // If X is unsigned and the new type is signed, then we only have to |
132 // check the upper limit, but we should cast the maximum value of the | |
133 // new type to an unsigned type before performing the comparison. | |
134 // This should always be OK because the maximum value should always be | |
135 // positive. | |
136 | |
5072 | 137 #define OCTAVE_US_S_FTR(T1, T2, TC) \ |
4943 | 138 template <> \ |
139 inline T2 \ | |
140 octave_int_fit_to_range<T1, T2> (const T1& x, const T2&, const T2& mx) \ | |
141 { \ | |
142 return x > static_cast<TC> (mx) ? mx : x; \ | |
143 } | |
144 | |
5072 | 145 #define OCTAVE_US_S_FTR_FCNS(T) \ |
146 OCTAVE_US_S_FTR (T, char, unsigned char) \ | |
147 OCTAVE_US_S_FTR (T, signed char, unsigned char) \ | |
148 OCTAVE_US_S_FTR (T, short, unsigned short) \ | |
149 OCTAVE_US_S_FTR (T, int, unsigned int) \ | |
150 OCTAVE_US_S_FTR (T, long, unsigned long) \ | |
151 OCTAVE_US_S_FTR (T, long long, unsigned long long) | |
4943 | 152 |
5072 | 153 OCTAVE_US_S_FTR_FCNS (unsigned char) |
154 OCTAVE_US_S_FTR_FCNS (unsigned short) | |
155 OCTAVE_US_S_FTR_FCNS (unsigned int) | |
156 OCTAVE_US_S_FTR_FCNS (unsigned long) | |
157 OCTAVE_US_S_FTR_FCNS (unsigned long long) | |
4943 | 158 |
159 // If X is signed and the new type is unsigned, then we only have to | |
160 // check the lower limit (which will always be 0 for an unsigned | |
161 // type). The upper limit will be enforced correctly by converting to | |
162 // the new type, even if the type of X is wider than the new type. | |
163 | |
5072 | 164 #define OCTAVE_S_US_FTR(T1, T2) \ |
4943 | 165 template <> \ |
166 inline T2 \ | |
167 octave_int_fit_to_range<T1, T2> (const T1& x, const T2&, const T2&) \ | |
168 { \ | |
5420 | 169 return x <= 0 ? 0 : x; \ |
4943 | 170 } |
171 | |
5072 | 172 #define OCTAVE_S_US_FTR_FCNS(T) \ |
173 OCTAVE_S_US_FTR (T, unsigned char) \ | |
174 OCTAVE_S_US_FTR (T, unsigned short) \ | |
175 OCTAVE_S_US_FTR (T, unsigned int) \ | |
176 OCTAVE_S_US_FTR (T, unsigned long) \ | |
177 OCTAVE_S_US_FTR (T, unsigned long long) | |
4943 | 178 |
5072 | 179 OCTAVE_S_US_FTR_FCNS (char) |
180 OCTAVE_S_US_FTR_FCNS (signed char) | |
181 OCTAVE_S_US_FTR_FCNS (short) | |
182 OCTAVE_S_US_FTR_FCNS (int) | |
183 OCTAVE_S_US_FTR_FCNS (long) | |
184 OCTAVE_S_US_FTR_FCNS (long long) | |
4943 | 185 |
4902 | 186 #define OCTAVE_INT_FIT_TO_RANGE(r, T) \ |
4943 | 187 octave_int_fit_to_range (r, \ |
188 std::numeric_limits<T>::min (), \ | |
189 std::numeric_limits<T>::max ()) | |
4902 | 190 |
191 #define OCTAVE_INT_MIN_VAL2(T1, T2) \ | |
192 std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::min () | |
193 | |
194 #define OCTAVE_INT_MAX_VAL2(T1, T2) \ | |
195 std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::max () | |
196 | |
197 #define OCTAVE_INT_FIT_TO_RANGE2(r, T1, T2) \ | |
198 octave_int_fit_to_range (r, \ | |
199 OCTAVE_INT_MIN_VAL2 (T1, T2), \ | |
200 OCTAVE_INT_MAX_VAL2 (T1, T2)) | |
201 | |
7534
ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
7521
diff
changeset
|
202 // We have all the machinery below (octave_int_helper) to avoid a few |
ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
7521
diff
changeset
|
203 // warnings from GCC about comparisons always false due to limited |
ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
7521
diff
changeset
|
204 // range of data types. Ugh. The cure may be worse than the disease. |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
205 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
206 // FIXME -- it would be nice to nest the helper class inside the |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
207 // octave_int class, but I don't see the magic for that at the moment. |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
208 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
209 template <class T> class octave_int; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
210 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
211 template <class T, bool is_signed> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
212 class octave_int_helper |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
213 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
214 public: |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
215 static octave_int<T> abs (const T& x); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
216 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
217 static octave_int<T> signum (const T& x); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
218 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
219 template <class T2> static void rshift_eq (T& ival, const T2& x); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
220 }; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
221 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
222 template <class T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
223 class octave_int_helper<T, false> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
224 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
225 public: |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
226 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
227 abs (const T& x) { return x; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
228 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
229 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
230 signum (const T& x) { return x > 0 ? 1 : 0; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
231 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
232 template <class T2> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
233 static void |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
234 rshift_eq (T& ival, const T2& x) { ival = ival >> x; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
235 }; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
236 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
237 template <class T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
238 class octave_int_helper<T, true> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
239 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
240 public: |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
241 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
242 abs (const T& x) { return x < 0 ? -x : x; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
243 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
244 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
245 signum (const T& x) { return x < 0 ? -1 : (x > 0 ? 1 : 0); } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
246 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
247 template <class T2> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
248 static void |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
249 rshift_eq (T& ival, const T2& x) |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
250 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
251 if (ival < 0) |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
252 ival = - (((-ival) >> x) & std::numeric_limits<T>::max()); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
253 else |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
254 ival = ival >> x; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
255 } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
256 }; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
257 |
4902 | 258 template <class T> |
259 class | |
260 octave_int | |
261 { | |
262 public: | |
263 | |
4943 | 264 typedef T val_type; |
265 | |
4902 | 266 octave_int (void) : ival () { } |
267 | |
268 template <class U> | |
269 octave_int (U i) : ival (OCTAVE_INT_FIT_TO_RANGE (i, T)) { } | |
270 | |
6402 | 271 octave_int (double d) : ival (OCTAVE_INT_FIT_TO_RANGE (xround (d), T)) { } |
272 | |
4902 | 273 octave_int (bool b) : ival (b) { } |
274 | |
275 template <class U> | |
276 octave_int (const octave_int<U>& i) | |
277 : ival (OCTAVE_INT_FIT_TO_RANGE (i.value (), T)) { } | |
278 | |
279 octave_int (const octave_int<T>& i) : ival (i.ival) { } | |
280 | |
281 octave_int& operator = (const octave_int<T>& i) | |
282 { | |
283 ival = i.ival; | |
284 return *this; | |
285 } | |
286 | |
287 ~octave_int (void) { } | |
288 | |
289 T value (void) const { return ival; } | |
290 | |
4949 | 291 const unsigned char * iptr (void) const |
292 { return reinterpret_cast<const unsigned char *> (& ival); } | |
293 | |
4902 | 294 bool operator ! (void) const { return ! ival; } |
295 | |
4906 | 296 octave_int<T> operator + (void) const { return *this; } |
4902 | 297 |
4906 | 298 octave_int<T> operator - (void) const |
4902 | 299 { |
4953 | 300 // Can't just return -ival because signed types are not |
301 // symmetric, which causes things like -intmin("int32") to be the | |
302 // same as intmin("int32") instead of intmax("int32") (which is | |
303 // what we should get with saturation semantics). | |
304 | |
305 return std::numeric_limits<T>::is_signed ? | |
306 OCTAVE_INT_FIT_TO_RANGE (- static_cast<double> (ival), T) : 0; | |
4902 | 307 } |
308 | |
7198 | 309 bool bool_value (void) const { return static_cast<bool> (value ()); } |
310 | |
311 char char_value (void) const { return static_cast<char> (value ()); } | |
312 | |
313 double double_value (void) const { return static_cast<double> (value ()); } | |
314 | |
315 float float_value (void) const { return static_cast<float> (value ()); } | |
316 | |
7177 | 317 operator T (void) const { return value (); } |
318 | |
7198 | 319 // char and bool operators intentionally omitted. |
5533 | 320 |
7198 | 321 operator double (void) const { return double_value (); } |
4902 | 322 |
7198 | 323 operator float (void) const { return float_value (); } |
5030 | 324 |
4902 | 325 octave_int<T>& operator += (const octave_int<T>& x) |
326 { | |
327 double t = static_cast<double> (value ()); | |
328 double tx = static_cast<double> (x.value ()); | |
329 ival = OCTAVE_INT_FIT_TO_RANGE (t + tx, T); | |
330 return *this; | |
331 } | |
332 | |
333 octave_int<T>& operator -= (const octave_int<T>& x) | |
334 { | |
335 double t = static_cast<double> (value ()); | |
336 double tx = static_cast<double> (x.value ()); | |
337 ival = OCTAVE_INT_FIT_TO_RANGE (t - tx, T); | |
338 return *this; | |
339 } | |
340 | |
4952 | 341 octave_int<T>& operator *= (const octave_int<T>& x) |
342 { | |
343 double t = static_cast<double> (value ()); | |
344 double tx = static_cast<double> (x.value ()); | |
345 ival = OCTAVE_INT_FIT_TO_RANGE (t * tx, T); | |
346 return *this; | |
347 } | |
348 | |
349 octave_int<T>& operator /= (const octave_int<T>& x) | |
350 { | |
351 double t = static_cast<double> (value ()); | |
352 double tx = static_cast<double> (x.value ()); | |
4968 | 353 double r = (t == 0 && tx == 0) ? 0 : xround (t / tx); |
4953 | 354 ival = OCTAVE_INT_FIT_TO_RANGE (r, T); |
4952 | 355 return *this; |
356 } | |
357 | |
358 template <class T2> | |
359 octave_int<T>& operator <<= (const T2& x) | |
360 { | |
6764 | 361 ival = ival << x; |
4952 | 362 return *this; |
363 } | |
364 | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
365 // Use helper functions in the operator >>=, abs, and signum |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
366 // functions to avoid "comparison of unsigned expression < 0 is |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
367 // always false" warnings from GCC when instantiating these funtions |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
368 // for unsigned types. |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
369 |
4952 | 370 template <class T2> |
371 octave_int<T>& operator >>= (const T2& x) | |
372 { | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
373 octave_int_helper<T, std::numeric_limits<T>::is_signed>::rshift_eq (ival, x); |
4952 | 374 return *this; |
375 } | |
376 | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
377 octave_int<T> abs (void) const |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
378 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
379 return octave_int_helper<T, std::numeric_limits<T>::is_signed>::abs (value ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
380 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
381 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
382 octave_int<T> signum (void) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
383 { |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
384 return octave_int_helper<T, std::numeric_limits<T>::is_signed>::signum (value ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
385 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
386 |
4906 | 387 octave_int<T> min (void) const { return std::numeric_limits<T>::min (); } |
388 octave_int<T> max (void) const { return std::numeric_limits<T>::max (); } | |
389 | |
4919 | 390 static int nbits (void) { return sizeof (T) * CHAR_BIT; } |
4909 | 391 |
4949 | 392 static int byte_size (void) { return sizeof(T); } |
393 | |
5900 | 394 // Unsafe. This function exists to support the MEX interface. |
395 // You should not use it anywhere else. | |
396 void *mex_get_data (void) const { return const_cast<T *> (&ival); } | |
397 | |
4902 | 398 private: |
399 | |
400 T ival; | |
401 }; | |
402 | |
403 template <class T> | |
4953 | 404 octave_int<T> |
405 pow (const octave_int<T>& a, const octave_int<T>& b) | |
4952 | 406 { |
4953 | 407 octave_int<T> retval; |
4952 | 408 |
4953 | 409 octave_int<T> zero = octave_int<T> (0); |
410 octave_int<T> one = octave_int<T> (1); | |
4952 | 411 |
412 if (b == zero) | |
413 retval = one; | |
414 else if (b < zero) | |
415 retval = zero; | |
416 else | |
417 { | |
4953 | 418 octave_int<T> a_val = a; |
419 octave_int<T> b_val = b; | |
4952 | 420 |
421 retval = a; | |
422 | |
423 b_val -= 1; | |
424 | |
5030 | 425 while (b_val != zero) |
4952 | 426 { |
5030 | 427 if ((b_val & one) != zero) |
4952 | 428 retval = retval * a_val; |
429 | |
430 b_val = b_val >> 1; | |
431 | |
432 if (b_val > zero) | |
433 a_val = a_val * a_val; | |
434 } | |
435 } | |
436 | |
437 return retval; | |
438 } | |
439 | |
440 template <class T> | |
4953 | 441 octave_int<T> |
442 pow (double a, const octave_int<T>& b) | |
443 { | |
444 double tb = static_cast<double> (b.value ()); | |
445 double r = pow (a, tb); | |
4968 | 446 r = lo_ieee_isnan (r) ? 0 : xround (r); |
4953 | 447 return OCTAVE_INT_FIT_TO_RANGE (r, T); |
448 } | |
449 | |
450 template <class T> | |
451 octave_int<T> | |
452 pow (const octave_int<T>& a, double b) | |
453 { | |
454 double ta = static_cast<double> (a.value ()); | |
455 double r = pow (ta, b); | |
4968 | 456 r = lo_ieee_isnan (r) ? 0 : xround (r); |
4953 | 457 return OCTAVE_INT_FIT_TO_RANGE (r, T); |
458 } | |
459 | |
460 template <class T> | |
4902 | 461 std::ostream& |
462 operator << (std::ostream& os, const octave_int<T>& ival) | |
463 { | |
464 os << ival.value (); | |
465 return os; | |
466 } | |
467 | |
468 template <class T> | |
469 std::istream& | |
470 operator >> (std::istream& is, octave_int<T>& ival) | |
471 { | |
472 T tmp = 0; | |
473 is >> tmp; | |
474 ival = tmp; | |
475 return is; | |
476 } | |
477 | |
5828 | 478 typedef octave_int<int8_t> octave_int8; |
479 typedef octave_int<int16_t> octave_int16; | |
480 typedef octave_int<int32_t> octave_int32; | |
481 typedef octave_int<int64_t> octave_int64; | |
4902 | 482 |
5828 | 483 typedef octave_int<uint8_t> octave_uint8; |
484 typedef octave_int<uint16_t> octave_uint16; | |
485 typedef octave_int<uint32_t> octave_uint32; | |
486 typedef octave_int<uint64_t> octave_uint64; | |
4902 | 487 |
488 #define OCTAVE_INT_BIN_OP(OP) \ | |
489 template <class T1, class T2> \ | |
490 octave_int<typename octave_int_binop_traits<T1, T2>::TR> \ | |
491 operator OP (const octave_int<T1>& x, const octave_int<T2>& y) \ | |
492 { \ | |
493 double tx = static_cast<double> (x.value ()); \ | |
494 double ty = static_cast<double> (y.value ()); \ | |
495 double r = tx OP ty; \ | |
496 return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); \ | |
4906 | 497 } |
4902 | 498 |
499 OCTAVE_INT_BIN_OP(+) | |
500 OCTAVE_INT_BIN_OP(-) | |
501 OCTAVE_INT_BIN_OP(*) | |
4953 | 502 |
503 template <class T1, class T2> | |
504 octave_int<typename octave_int_binop_traits<T1, T2>::TR> | |
505 operator / (const octave_int<T1>& x, const octave_int<T2>& y) | |
506 { | |
507 double tx = static_cast<double> (x.value ()); | |
508 double ty = static_cast<double> (y.value ()); | |
6402 | 509 double r = (tx == 0 && ty == 0) ? 0 : xround (tx / ty); |
4953 | 510 return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); |
511 } | |
512 | |
513 #define OCTAVE_INT_DOUBLE_BIN_OP(OP) \ | |
514 template <class T> \ | |
515 octave_int<T> \ | |
516 operator OP (const octave_int<T>& x, double y) \ | |
517 { \ | |
518 double tx = static_cast<double> (x.value ()); \ | |
4968 | 519 double r = xround (tx OP y); \ |
520 r = lo_ieee_isnan (r) ? 0 : xround (r); \ | |
4953 | 521 return OCTAVE_INT_FIT_TO_RANGE (r, T); \ |
522 } | |
523 | |
524 OCTAVE_INT_DOUBLE_BIN_OP(+) | |
525 OCTAVE_INT_DOUBLE_BIN_OP(-) | |
526 OCTAVE_INT_DOUBLE_BIN_OP(*) | |
527 OCTAVE_INT_DOUBLE_BIN_OP(/) | |
528 | |
529 #define OCTAVE_DOUBLE_INT_BIN_OP(OP) \ | |
530 template <class T> \ | |
531 octave_int<T> \ | |
532 operator OP (double x, const octave_int<T>& y) \ | |
533 { \ | |
534 double ty = static_cast<double> (y.value ()); \ | |
535 double r = x OP ty; \ | |
4968 | 536 r = lo_ieee_isnan (r) ? 0 : xround (r); \ |
4953 | 537 return OCTAVE_INT_FIT_TO_RANGE (r, T); \ |
538 } | |
539 | |
540 OCTAVE_DOUBLE_INT_BIN_OP(+) | |
541 OCTAVE_DOUBLE_INT_BIN_OP(-) | |
542 OCTAVE_DOUBLE_INT_BIN_OP(*) | |
543 OCTAVE_DOUBLE_INT_BIN_OP(/) | |
4902 | 544 |
5029 | 545 #define OCTAVE_INT_DOUBLE_CMP_OP(OP) \ |
546 template <class T> \ | |
547 bool \ | |
548 operator OP (const octave_int<T>& x, const double& y) \ | |
549 { \ | |
550 double tx = static_cast<double> (x.value ()); \ | |
5030 | 551 return tx OP y; \ |
5029 | 552 } |
553 | |
554 OCTAVE_INT_DOUBLE_CMP_OP (<) | |
555 OCTAVE_INT_DOUBLE_CMP_OP (<=) | |
556 OCTAVE_INT_DOUBLE_CMP_OP (>=) | |
557 OCTAVE_INT_DOUBLE_CMP_OP (>) | |
558 OCTAVE_INT_DOUBLE_CMP_OP (==) | |
559 OCTAVE_INT_DOUBLE_CMP_OP (!=) | |
560 | |
561 #define OCTAVE_DOUBLE_INT_CMP_OP(OP) \ | |
562 template <class T> \ | |
563 bool \ | |
564 operator OP (const double& x, const octave_int<T>& y) \ | |
565 { \ | |
566 double ty = static_cast<double> (y.value ()); \ | |
5030 | 567 return x OP ty; \ |
5029 | 568 } |
569 | |
570 OCTAVE_DOUBLE_INT_CMP_OP (<) | |
571 OCTAVE_DOUBLE_INT_CMP_OP (<=) | |
572 OCTAVE_DOUBLE_INT_CMP_OP (>=) | |
573 OCTAVE_DOUBLE_INT_CMP_OP (>) | |
574 OCTAVE_DOUBLE_INT_CMP_OP (==) | |
575 OCTAVE_DOUBLE_INT_CMP_OP (!=) | |
576 | |
4906 | 577 #define OCTAVE_INT_BITCMP_OP(OP) \ |
578 template <class T> \ | |
579 octave_int<T> \ | |
580 operator OP (const octave_int<T>& x, const octave_int<T>& y) \ | |
581 { \ | |
582 return x.value () OP y.value (); \ | |
583 } | |
584 | |
585 OCTAVE_INT_BITCMP_OP (&) | |
586 OCTAVE_INT_BITCMP_OP (|) | |
587 OCTAVE_INT_BITCMP_OP (^) | |
588 | |
4952 | 589 template <class T1, class T2> |
590 octave_int<T1> | |
591 operator << (const octave_int<T1>& x, const T2& y) | |
592 { | |
5030 | 593 octave_int<T1> retval = x; |
4952 | 594 return retval <<= y; |
595 } | |
4906 | 596 |
4952 | 597 template <class T1, class T2> |
598 octave_int<T1> | |
599 operator >> (const octave_int<T1>& x, const T2& y) | |
600 { | |
5030 | 601 octave_int<T1> retval = x; |
4952 | 602 return retval >>= y; |
603 } | |
4906 | 604 |
4909 | 605 template <class T> |
606 octave_int<T> | |
4920 | 607 bitshift (const octave_int<T>& a, int n, |
608 const octave_int<T>& mask = std::numeric_limits<T>::max ()) | |
4909 | 609 { |
610 if (n > 0) | |
4952 | 611 return (a << n) & mask; |
4909 | 612 else if (n < 0) |
4952 | 613 return (a >> -n) & mask; |
4909 | 614 else |
615 return a; | |
616 } | |
617 | |
4902 | 618 #define OCTAVE_INT_CMP_OP(OP) \ |
619 template <class T1, class T2> \ | |
620 bool \ | |
621 operator OP (const octave_int<T1>& x, const octave_int<T2>& y) \ | |
622 { \ | |
5072 | 623 return x.value () OP y.value (); \ |
4906 | 624 } |
4902 | 625 |
626 OCTAVE_INT_CMP_OP (<) | |
627 OCTAVE_INT_CMP_OP (<=) | |
628 OCTAVE_INT_CMP_OP (>=) | |
629 OCTAVE_INT_CMP_OP (>) | |
630 OCTAVE_INT_CMP_OP (==) | |
631 OCTAVE_INT_CMP_OP (!=) | |
632 | |
5072 | 633 // The following apply if the unsigned type is at least as wide as the |
634 // signed type (then we can cast postive signed values to the unsigned | |
635 // type and compare). | |
636 | |
637 #define OCTAVE_US_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
638 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
639 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
640 OCTAVE_API operator OP (const octave_int<UT>& lhs, const octave_int<ST>& rhs); |
5072 | 641 |
642 #define OCTAVE_US_TYPE1_CMP_OP_DECLS(UT, ST) \ | |
643 OCTAVE_US_TYPE1_CMP_OP_DECL (<, false, UT, ST) \ | |
644 OCTAVE_US_TYPE1_CMP_OP_DECL (<=, false, UT, ST) \ | |
645 OCTAVE_US_TYPE1_CMP_OP_DECL (>=, true, UT, ST) \ | |
646 OCTAVE_US_TYPE1_CMP_OP_DECL (>, true, UT, ST) \ | |
647 OCTAVE_US_TYPE1_CMP_OP_DECL (==, false, UT, ST) \ | |
648 OCTAVE_US_TYPE1_CMP_OP_DECL (!=, true, UT, ST) | |
649 | |
650 #define OCTAVE_SU_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
651 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
652 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
653 OCTAVE_API operator OP (const octave_int<ST>& lhs, const octave_int<UT>& rhs); |
5072 | 654 |
655 #define OCTAVE_SU_TYPE1_CMP_OP_DECLS(ST, UT) \ | |
656 OCTAVE_SU_TYPE1_CMP_OP_DECL (<, true, ST, UT) \ | |
657 OCTAVE_SU_TYPE1_CMP_OP_DECL (<=, true, ST, UT) \ | |
658 OCTAVE_SU_TYPE1_CMP_OP_DECL (>=, false, ST, UT) \ | |
659 OCTAVE_SU_TYPE1_CMP_OP_DECL (>, false, ST, UT) \ | |
660 OCTAVE_SU_TYPE1_CMP_OP_DECL (==, false, ST, UT) \ | |
661 OCTAVE_SU_TYPE1_CMP_OP_DECL (!=, true, ST, UT) | |
662 | |
663 #define OCTAVE_TYPE1_CMP_OP_DECLS(UT, ST) \ | |
664 OCTAVE_US_TYPE1_CMP_OP_DECLS (UT, ST) \ | |
665 OCTAVE_SU_TYPE1_CMP_OP_DECLS (ST, UT) | |
666 | |
5828 | 667 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int8_t) |
668 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int16_t) | |
669 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int32_t) | |
5072 | 670 |
5828 | 671 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int8_t) |
672 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int16_t) | |
673 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int32_t) | |
674 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int64_t) | |
5072 | 675 |
676 // The following apply if the signed type is wider than the unsigned | |
677 // type (then we can cast unsigned values to the signed type and | |
678 // compare if the signed value is positive). | |
679 | |
680 #define OCTAVE_US_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
681 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
682 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
683 OCTAVE_API operator OP (const octave_int<UT>& lhs, const octave_int<ST>& rhs); |
5072 | 684 |
685 #define OCTAVE_US_TYPE2_CMP_OP_DECLS(ST, UT) \ | |
686 OCTAVE_US_TYPE2_CMP_OP_DECL (<, false, ST, UT) \ | |
687 OCTAVE_US_TYPE2_CMP_OP_DECL (<=, false, ST, UT) \ | |
688 OCTAVE_US_TYPE2_CMP_OP_DECL (>=, true, ST, UT) \ | |
689 OCTAVE_US_TYPE2_CMP_OP_DECL (>, true, ST, UT) \ | |
690 OCTAVE_US_TYPE2_CMP_OP_DECL (==, false, ST, UT) \ | |
691 OCTAVE_US_TYPE2_CMP_OP_DECL (!=, true, ST, UT) | |
692 | |
693 #define OCTAVE_SU_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
694 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
695 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
696 OCTAVE_API operator OP (const octave_int<ST>& lhs, const octave_int<UT>& rhs); |
5072 | 697 |
698 #define OCTAVE_SU_TYPE2_CMP_OP_DECLS(ST, UT) \ | |
699 OCTAVE_SU_TYPE2_CMP_OP_DECL (<, true, ST, UT) \ | |
700 OCTAVE_SU_TYPE2_CMP_OP_DECL (<=, true, ST, UT) \ | |
701 OCTAVE_SU_TYPE2_CMP_OP_DECL (>=, false, ST, UT) \ | |
702 OCTAVE_SU_TYPE2_CMP_OP_DECL (>, false, ST, UT) \ | |
703 OCTAVE_SU_TYPE2_CMP_OP_DECL (==, false, ST, UT) \ | |
704 OCTAVE_SU_TYPE2_CMP_OP_DECL (!=, true, ST, UT) | |
705 | |
706 #define OCTAVE_TYPE2_CMP_OP_DECLS(UT, ST) \ | |
707 OCTAVE_US_TYPE2_CMP_OP_DECLS (UT, ST) \ | |
708 OCTAVE_SU_TYPE2_CMP_OP_DECLS (ST, UT) | |
709 | |
5828 | 710 OCTAVE_TYPE2_CMP_OP_DECLS (uint32_t, int64_t) |
5072 | 711 |
4902 | 712 #undef OCTAVE_INT_BINOP_TRAIT |
5072 | 713 #undef OCTAVE_US_S_FTR |
714 #undef OCTAVE_US_S_FTR_FCNS | |
715 #undef OCTAVE_S_US_FTR | |
716 #undef OCTAVE_S_US_FTR_FCNS | |
4902 | 717 #undef OCTAVE_INT_FIT_TO_RANGE |
718 #undef OCTAVE_INT_MIN_VAL2 | |
719 #undef OCTAVE_INT_MAX_VAL2 | |
720 #undef OCTAVE_INT_FIT_TO_RANGE2 | |
721 #undef OCTAVE_INT_BIN_OP | |
5072 | 722 #undef OCTAVE_INT_DOUBLE_BIN_OP |
723 #undef OCTAVE_DOUBLE_INT_BIN_OP | |
724 #undef OCTAVE_INT_DOUBLE_CMP_OP | |
725 #undef OCTAVE_DOUBLE_INT_CMP_OP | |
726 #undef OCTAVE_INT_BITCMP_OP | |
4902 | 727 #undef OCTAVE_INT_CMP_OP |
5072 | 728 #undef OCTAVE_US_TYPE1_CMP_OP_DECL |
729 #undef OCTAVE_US_TYPE1_CMP_OP_DECLS | |
730 #undef OCTAVE_SU_TYPE1_CMP_OP_DECL | |
731 #undef OCTAVE_SU_TYPE1_CMP_OP_DECLS | |
732 #undef OCTAVE_TYPE1_CMP_OP_DECLS | |
733 #undef OCTAVE_US_TYPE2_CMP_OP_DECL | |
734 #undef OCTAVE_US_TYPE2_CMP_OP_DECLS | |
735 #undef OCTAVE_SU_TYPE2_CMP_OP_DECL | |
736 #undef OCTAVE_SU_TYPE2_CMP_OP_DECLS | |
5074 | 737 #undef OCTAVE_TYPE2_CMP_OP_DECLS |
4902 | 738 |
739 #endif | |
740 | |
741 /* | |
742 ;;; Local Variables: *** | |
743 ;;; mode: C++ *** | |
744 ;;; End: *** | |
745 */ |