-
Notifications
You must be signed in to change notification settings - Fork 3
/
ZeroTypes.h
3883 lines (3718 loc) · 173 KB
/
ZeroTypes.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
ZeroTypes Library
Open source license: BSD
(http://github.com/h3rb/ZeroTypes)
Author: H. Elwood Gilliland III
Copyright (c) 2007-2017
*/
#pragma once
#pragma warning (disable:4100)
#pragma warning (disable:4101)
// Call this on application startup. Inits work strings and the seeder.
void InitZeroTypesLibrary();
void ZIndexed_Rigorous_Test();
#include <string>
#include <cmath>
#if !defined(DEBUG) && defined(_DEBUG)
#define DEBUG _DEBUG
#endif
#ifdef DEBUG
#define OUTPUT(str,...) output__(str, ##__VA_ARGS__)
#else
#define OUTPUT(std,...)
#endif
// having, true-or-false (diminished meaning of bool) parameter specifiers...
// Used to mark a parameter being presented a bool as a signal rather than a parameter-as-tested-value signal. (See implementation...)
typedef bool trueorfalse;
typedef bool having; // symbol name idea came after reading about /using/ C++ keyword on http://stackoverflow.com/questions/10747810/what-is-the-difference-between-typedef-and-using-in-c11
// Sometimes the implementation uses the presence of a bool typed parameter to allow for a quick variant of a function/method of same name
// Example can be seen in GridSplitter where presence of "columns_instead_of_rows" parameter activates the feature whether presented with true or false.
// This is a slight brainly optimization that adds functionality where it was already present, and the typedef(s) above simplify programmer interface by
// embedding the nuance right in the code. Most compilers would treat this as an alias, so bool and Zbool can still be provided when cast,
// but if you see /having/, passing it a bool variable isn't meaningful, you must test its value if it is to mean something. The alternative
// would be to collude the code with cryptic numbers like "Concatenate2..." ... which is also done in some places, but is avoided where-ever possible.
// Prior to creating these typedefs, the implementation did not specify when true or false would lead to the feature being activated at the parameter level.
// Basic cross-platform soft error reporting function.
// Put a breakpoint on the calls to this to catch your issues with the debugger in debug mode.
void output__(const char *fmt, ...);
// Basic cross-platform string formatting printf style
std::string FMT(const char *fmt, ...);
// POD-type replacements
#define Zb Zbool
#define Zi Zint
#define Zf Zfloat
#define Zd Zdouble
#define Zui Zuint
#define Zus Zushort
// Divide by zero protection and report
#define DIV_BY_ZERO_PROTECTION 1
#if !defined(DIV_BY_ZERO_REPORTING) && ( defined(_DEBUG) || defined(DEBUG) || defined(DEBUG_OUTPUT) )
//#define DIV_BY_ZERO_REPORTING 1
// Use /D compiler option to set
#endif
// Unsigned subtraction "wrap" protection and report
#define UNSIGNED_SUBTRACTION_WRAP_PROTECTION 1
#if !defined(UNSIGNED_SUBTRACTION_WRAP_REPORTING) && ( defined(_DEBUG) || defined(DEBUG) || defined(DEBUG_OUTPUT) )
#define UNSIGNED_SUBTRACTION_WRAP_REPORTING 1
#endif
// Unsigned addition "wrap" protection and report
#define UNSIGNED_ADDITION_WRAP_PROTECTION 1
#if !defined(UNSIGNED_ADDITION_WRAP_REPORTING) && ( defined(_DEBUG) || defined(DEBUG) || defined(DEBUG_OUTPUT) )
#define UNSIGNED_ADDITION_WRAP_REPORTING 1
#endif
// Unsigned multiplication "wrap" protection and report
#define UNSIGNED_MULTIPLY_WRAP_PROTECTION 1
#if !defined(UNSIGNED_MULTIPLY_WRAP_REPORTING) && ( defined(_DEBUG) || defined(DEBUG) || defined(DEBUG_OUTPUT) )
#define UNSIGNED_MULTIPLY_WRAP_REPORTING 1
#endif
/// Zbool /////////////////////////////////////////////////////////////////////////////////////////// start
class Zbool {
public:
bool value;
Zbool() { value=false; }
Zbool( bool b ) { this->value=b; }
operator bool *() { return &value; }
Zbool *operator()() { return this; }
Zbool& operator= ( const bool b ) { value=b; return *this; }
Zbool& operator|= ( const bool b ) { value|=b; return *this; }
Zbool& operator&= ( const bool b ) { value&=b; return *this; }
const bool operator-() { return !value; }
operator bool() { return value; }
};
/// Zbool /////////////////////////////////////////////////////////////////////////////////////////// end
/// Zwas //////////////////////////////////////////////////////////////////////////////////////////// start
class Zwas {
public:
bool value,was;
Zwas() { value=was=false; }
Zwas( bool b ) { this->value=b; was=false; }
operator bool *() { return &value; }
Zwas *operator()() { return this; }
Zwas& operator= ( const bool b ) { was=value; value=b; return *this; }
Zwas& operator|= ( const bool b ) { value|=b; return *this; }
Zwas& operator&= ( const bool b ) { value&=b; return *this; }
void Store() {
was=value;
}
const bool operator-() { return !value; }
operator bool() { return value; }
};
/// Zwas //////////////////////////////////////////////////////////////////////////////////////////// end
// Forward declarations
class Zbyte;
class Zushort;
class Zuint;
class Zint;
class Zdouble;
/// Zfloat ////////////////////////////////////////////////////////////////////////////////////////// start
class Zfloat {
public:
float value;
Zfloat() { value=0.0f; }
Zfloat( float value ) { this->value=value; }
std::string toString() { return std::to_string(value);}
float abs() { return std::abs(value); }
operator std::string() { return toString(); }
operator float() { return value; }
operator float *() { return &value; }
Zfloat *operator()() { return this; }
float operator()( int i ) { return value=(float)i; }
float operator()( float f ) { return value=f; }
float operator()( double d ) { return value=(float)d; }
float operator()( Zbyte &b );
float operator()( Zuint &i );
float operator()( Zint &i );
float operator()( Zfloat &f );
float operator()( Zdouble &d );
Zfloat& operator= ( const unsigned char b ) { value=(float) b; return *this; }
Zfloat& operator= ( const unsigned int i ) { value=(float) i; return *this; }
Zfloat& operator= ( const int i ) { value=(float) i; return *this; }
Zfloat& operator= ( const float f ) { value=f; return *this; }
Zfloat& operator= ( const double d ) { value=(float) d; return *this; }
Zfloat& operator= ( const Zbyte& b );
Zfloat& operator= ( const Zuint& i );
Zfloat& operator= ( const Zint& i );
Zfloat& operator= ( const Zfloat& f ) { value=f.value; return *this; }
Zfloat& operator= ( const Zdouble& d );
Zfloat& operator= ( const std::string& s );
Zfloat& operator+= ( const Zfloat& f ) { value+=f.value; return *this; }
Zfloat& operator-= ( const Zfloat& f ) { value-=f.value; return *this; }
Zfloat& operator*= ( const Zfloat& f ) { value*=f.value; return *this; }
Zfloat& operator/= ( const Zfloat& f ) { value/=f.value; return *this; }
Zfloat& operator+= ( const Zint& i );
Zfloat& operator-= ( const Zint& i );
Zfloat& operator*= ( const Zint& i );
Zfloat& operator/= ( const Zint& i );
Zfloat& operator+= ( const unsigned char f ) { value+=(float)f; return *this; }
Zfloat& operator-= ( const unsigned char f ) { value-=(float)f; return *this; }
Zfloat& operator*= ( const unsigned char f ) { value*=(float)f; return *this; }
Zfloat& operator/= ( const unsigned char f ) { value/=(float)f; return *this; }
Zfloat& operator+= ( const unsigned short f ) { value+=(float)f; return *this; }
Zfloat& operator-= ( const unsigned short f ) { value-=(float)f; return *this; }
Zfloat& operator*= ( const unsigned short f ) { value*=(float)f; return *this; }
Zfloat& operator/= ( const unsigned short f ) { value/=(float)f; return *this; }
Zfloat& operator+= ( const int f ) { value+=(float)f; return *this; }
Zfloat& operator-= ( const int f ) { value-=(float)f; return *this; }
Zfloat& operator*= ( const int f ) { value*=(float)f; return *this; }
Zfloat& operator/= ( const int f ) { value/=(float)f; return *this; }
Zfloat& operator+= ( const unsigned int f ) { value+=(float)f; return *this; }
Zfloat& operator-= ( const unsigned int f ) { value-=(float)f; return *this; }
Zfloat& operator*= ( const unsigned int f ) { value*=(float)f; return *this; }
Zfloat& operator/= ( const unsigned int f ) { value/=(float)f; return *this; }
Zfloat& operator+= ( const float f ) { value+=f; return *this; }
Zfloat& operator-= ( const float f ) { value-=f; return *this; }
Zfloat& operator*= ( const float f ) { value*=f; return *this; }
Zfloat& operator/= ( const float f ) { value/=f; return *this; }
Zfloat& operator+= ( const double f ) { value+=(float)f; return *this; }
Zfloat& operator-= ( const double f ) { value-=(float)f; return *this; }
Zfloat& operator*= ( const double f ) { value*=(float)f; return *this; }
Zfloat& operator/= ( const double f ) { value/=(float)f; return *this; }
Zfloat& operator++ (int) { value+=1.0f; return *this; }
Zfloat& operator-- (int) { value-=1.0f; return *this; }
const float operator-() { return -value; }
bool operator !() { return ( value == 0.0f ); }
// Not used intentionally to create warning:
// operator double() { return (double) value; }
// operator int() { return (int) value; }
// Causes ambiguity, because this is removed, the resulting issue (no better solution, see C2593)
// (mixed type comparisons require explicit casts) is described in the test:
// operator double() { return (double) value; }
// operator int() { return (int) value; }
};
// Mixed type interactions
float operator+ ( const Zfloat& a, const Zint& b );
float operator+ ( const Zint& a, const Zfloat& b );
float operator* ( const Zfloat& a, const Zint& b );
float operator* ( const Zint& a, const Zfloat& b );
// Float and itself
float operator+ ( const Zfloat& a, const Zfloat& b );
float operator- ( const Zfloat& a, const Zfloat& b );
float operator* ( const Zfloat& a, const Zfloat& b );
float operator/ ( const Zfloat& a, const Zfloat& b );
/* Creates C2593 for some reason...
float operator+ ( Zfloat a, Zfloat b );
float operator- ( Zfloat a, Zfloat b );
float operator* ( Zfloat a, Zfloat b );
float operator/ ( Zfloat a, Zfloat b );
*/
// Casted int operations
float operator+ ( const Zfloat& a, int b );
float operator- ( const Zfloat& a, int b );
float operator* ( const Zfloat& a, int b );
float operator/ ( const Zfloat& a, int b );
float operator+ ( int b, const Zfloat& a );
float operator- ( int b, const Zfloat& a );
float operator* ( int b, const Zfloat& a );
float operator/ ( int b, const Zfloat& a );
// Float operations
float operator+ ( const Zfloat& a, float b );
float operator- ( const Zfloat& a, float b );
float operator* ( const Zfloat& a, float b );
float operator/ ( const Zfloat& a, float b );
float operator+ ( float b, const Zfloat& a );
float operator- ( float b, const Zfloat& a );
float operator* ( float b, const Zfloat& a );
float operator/ ( float b, const Zfloat& a );
// Casted double operations (leans toward double precision)
float operator+ ( const Zfloat& a, double b );
float operator- ( const Zfloat& a, double b );
float operator* ( const Zfloat& a, double b );
float operator/ ( const Zfloat& a, double b );
float operator+ ( double b, const Zfloat& a );
float operator- ( double b, const Zfloat& a );
float operator* ( double b, const Zfloat& a );
float operator/ ( double b, const Zfloat& a );
// Boolean operations
bool operator>= ( const Zfloat& a, const Zfloat& b );
bool operator>= ( const Zfloat& a, const Zbyte& b );
bool operator>= ( const Zfloat& a, const Zushort& b );
bool operator>= ( const Zfloat& a, const Zuint& b );
bool operator>= ( const Zfloat& a, const Zint& b );
bool operator>= ( const Zfloat& a, const Zdouble& b );
bool operator>= ( const Zbyte& a, const Zfloat& b );
bool operator>= ( const Zushort& a, const Zfloat& b );
bool operator>= ( const Zuint& a, const Zfloat& b );
bool operator>= ( const Zint& a, const Zfloat& b );
bool operator>= ( const Zdouble& a, const Zfloat& b );
bool operator>= ( const Zfloat& a, int b );
bool operator>= ( const Zfloat& a, float b );
bool operator>= ( const Zfloat& a, double b );
bool operator>= ( int a, const Zfloat& b );
bool operator>= ( float a, const Zfloat& b );
bool operator>= ( double a, const Zfloat& b );
bool operator== ( const Zfloat& a, const Zfloat& b );
bool operator== ( const Zfloat& a, const Zbyte& b );
bool operator== ( const Zfloat& a, const Zushort& b );
bool operator== ( const Zfloat& a, const Zuint& b );
bool operator== ( const Zfloat& a, const Zint& b );
bool operator== ( const Zfloat& a, const Zdouble& b );
bool operator== ( const Zbyte& a, const Zfloat& b );
bool operator== ( const Zushort& a, const Zfloat& b );
bool operator== ( const Zuint& a, const Zfloat& b );
bool operator== ( const Zint& a, const Zfloat& b );
bool operator== ( const Zdouble& a, const Zfloat& b );
bool operator== ( const Zfloat& a, int b );
bool operator== ( const Zfloat& a, float b );
bool operator== ( const Zfloat& a, double b );
bool operator== ( int a, const Zfloat& b );
bool operator== ( float a, const Zfloat& b );
bool operator== ( double a, const Zfloat& b );
bool operator!= ( const Zfloat& a, const Zfloat& b );
bool operator!= ( const Zfloat& a, const Zbyte& b );
bool operator!= ( const Zfloat& a, const Zushort& b );
bool operator!= ( const Zfloat& a, const Zuint& b );
bool operator!= ( const Zfloat& a, const Zint& b );
bool operator!= ( const Zfloat& a, const Zdouble& b );
bool operator!= ( const Zbyte& a, const Zfloat& b );
bool operator!= ( const Zushort& a, const Zfloat& b );
bool operator!= ( const Zuint& a, const unsigned int b );
bool operator!= ( const Zuint& a, const int b );
bool operator!= ( const Zuint& a, const Zfloat& b );
bool operator!= ( const Zint& a, const Zfloat& b );
bool operator!= ( const Zdouble& a, const Zfloat& b );
bool operator!= ( const Zfloat& a, int b );
bool operator!= ( const Zfloat& a, float b );
bool operator!= ( const Zfloat& a, double b );
bool operator!= ( int a, const Zfloat& b );
bool operator!= ( float a, const Zfloat& b );
bool operator!= ( double a, const Zfloat& b );
bool operator<= ( const Zfloat& a, const Zfloat& b );
bool operator<= ( const Zfloat& a, const Zbyte& b );
bool operator<= ( const Zfloat& a, const Zushort& b );
bool operator<= ( const Zfloat& a, const Zuint& b );
bool operator<= ( const Zfloat& a, const Zint& b );
bool operator<= ( const Zfloat& a, const Zdouble& b );
bool operator<= ( const Zbyte& a, const Zfloat& b );
bool operator<= ( const Zushort& a, const Zfloat& b );
bool operator<= ( const Zuint& a, const Zfloat& b );
bool operator<= ( const Zint& a, const Zfloat& b );
bool operator<= ( const Zdouble& a, const Zfloat& b );
bool operator<= ( const Zfloat& a, int b );
bool operator<= ( const Zfloat& a, float b );
bool operator<= ( const Zfloat& a, double b );
bool operator<= ( int a, const Zfloat& b );
bool operator<= ( float a, const Zfloat& b );
bool operator<= ( double a, const Zfloat& b );
bool operator> ( const Zfloat& a, const Zfloat& b );
bool operator> ( const Zfloat& a, const Zbyte& b );
bool operator> ( const Zfloat& a, const Zushort& b );
bool operator> ( const Zfloat& a, const Zuint& b );
bool operator> ( const Zfloat& a, const Zint& b );
bool operator> ( const Zfloat& a, const Zdouble& b );
bool operator> ( const Zbyte& a, const Zfloat& b );
bool operator> ( const Zushort& a, const Zfloat& b );
bool operator> ( const Zuint& a, const Zfloat& b );
bool operator> ( const Zint& a, const Zfloat& b );
bool operator> ( const Zdouble& a, const Zfloat& b );
bool operator> ( const Zfloat& a, int b );
bool operator> ( const Zfloat& a, float b );
bool operator> ( const Zfloat& a, double b );
bool operator> ( int a, const Zfloat& b );
bool operator> ( float a, const Zfloat& b );
bool operator> ( double a, const Zfloat& b );
bool operator< ( const Zfloat& a, const Zfloat& b );
bool operator< ( const Zfloat& a, const Zbyte& b );
bool operator< ( const Zfloat& a, const Zushort& b );
bool operator< ( const Zfloat& a, const Zuint& b );
bool operator< ( const Zfloat& a, const Zint& b );
bool operator< ( const Zfloat& a, const Zdouble& b );
bool operator< ( const Zbyte& a, const Zfloat& b );
bool operator< ( const Zushort& a, const Zfloat& b );
bool operator< ( const Zuint& a, const Zfloat& b );
bool operator< ( const Zint& a, const Zfloat& b );
bool operator< ( const Zdouble& a, const Zfloat& b );
bool operator< ( const Zfloat& a, int b );
bool operator< ( const Zfloat& a, float b );
bool operator< ( const Zfloat& a, double b );
bool operator< ( int a, const Zfloat& b );
bool operator< ( float a, const Zfloat& b );
bool operator< ( double a, const Zfloat& b );
/// Zfloat ////////////////////////////////////////////////////////////////////////////////////////// end
/// Zbyte ////////////////////////////////////////////////////////////////////////////////////////// start
class Zbyte {
public:
unsigned char value;
Zbyte() { value=0; }
Zbyte( unsigned char value ) { this->value=value; }
operator unsigned char *() { return &value; }
Zbyte *operator()() { return this; }
bool Get(const unsigned char bit) { return ((value) & (1<<(bit))) ? true : false; }
void Set(const unsigned char bit, const bool on) { if (on) value |= (bit); else value &= ~(bit); }
unsigned char operator()( unsigned char b ) { return value=b; }
unsigned char operator()( unsigned int i ) { return value=(unsigned char)i; }
unsigned char operator()( int i ) { return value=(unsigned char) i; }
unsigned char operator()( float f ) { return value=(unsigned char) f; }
unsigned char operator()( double d ) { return value=(unsigned char) d; }
unsigned char operator()( Zuint &i );
unsigned char operator()( Zint &i );
unsigned char operator()( Zfloat &f );
unsigned char operator()( Zdouble &d );
Zbyte& operator= ( const unsigned char b ) { value=b; return *this; }
Zbyte& operator= ( const int i ) { value=(unsigned char)i; return *this; }
Zbyte& operator= ( const float f ) { value=(unsigned char)f; return *this; }
Zbyte& operator= ( const double d ) { value=(unsigned char) d; return *this; }
Zbyte& operator= ( const Zbyte& i ) { value=i.value; return *this; }
Zbyte& operator= ( const Zuint& i );
Zbyte& operator= ( const Zint& i );
Zbyte& operator= ( const Zfloat& f );
Zbyte& operator= ( const Zdouble& d );
Zbyte& operator= ( const std::string& s );
Zbyte& operator+= ( const Zbyte& i ) { value+=i.value; return *this; }
Zbyte& operator-= ( const Zbyte& i ) { value-=i.value; return *this; }
Zbyte& operator*= ( const Zbyte& i ) { value*=i.value; return *this; }
Zbyte& operator/= ( const Zbyte& i ) { value/=i.value; return *this; }
Zbyte& operator+= ( const unsigned char i ) { value+=i; return *this; }
Zbyte& operator-= ( const unsigned char i ) { value-=i; return *this; }
Zbyte& operator*= ( const unsigned char i ) { value*=i; return *this; }
Zbyte& operator/= ( const unsigned char i ) { value/=i; return *this; }
Zbyte& operator+= ( const unsigned short i ) { value+=(unsigned char)i; return *this; }
Zbyte& operator-= ( const unsigned short i ) { value-=(unsigned char)i; return *this; }
Zbyte& operator*= ( const unsigned short i ) { value*=(unsigned char)i; return *this; }
Zbyte& operator/= ( const unsigned short i ) { value/=(unsigned char)i; return *this; }
Zbyte& operator+= ( const int i ) { value+=(unsigned char)i; return *this; }
Zbyte& operator-= ( const int i ) { value-=(unsigned char)i; return *this; }
Zbyte& operator*= ( const int i ) { value*=(unsigned char)i; return *this; }
Zbyte& operator/= ( const int i ) { value/=(unsigned char)i; return *this; }
Zbyte& operator+= ( const unsigned int i ) { value+=(unsigned char)i; return *this; }
Zbyte& operator-= ( const unsigned int i ) { value-=(unsigned char)i; return *this; }
Zbyte& operator*= ( const unsigned int i ) { value*=(unsigned char)i; return *this; }
Zbyte& operator/= ( const unsigned int i ) { value/=(unsigned char)i; return *this; }
Zbyte& operator+= ( const float i ) { value+=(unsigned char)i; return *this; }
Zbyte& operator-= ( const float i ) { value-=(unsigned char)i; return *this; }
Zbyte& operator*= ( const float i ) { value*=(unsigned char)i; return *this; }
Zbyte& operator/= ( const float i ) { value/=(unsigned char)i; return *this; }
Zbyte& operator+= ( const double i ) { value+=(unsigned char)i; return *this; }
Zbyte& operator-= ( const double i ) { value-=(unsigned char)i; return *this; }
Zbyte& operator*= ( const double i ) { value*=(unsigned char)i; return *this; }
Zbyte& operator/= ( const double i ) { value/=(unsigned char)i; return *this; }
Zbyte& operator++ (int) { value+=1; return *this; }
Zbyte& operator-- (int) { value-=1; return *this; }
operator unsigned char() { return value; }
bool operator !() { return ( value == 0 ); }
// Not used intentionally to create warning:
// operator float() { return (float)value; }
// operator double() { return (double)value; }
// Causes ambiguity, because this is removed, the resulting issue (no better solution, see C2593)
// (mixed type comparisons require explicit casts) is described in the test:
// operator float() { return (float) value; }
// operator float() { return (double) value; }
};
unsigned char operator+ ( const Zbyte& a, const Zbyte& b );
unsigned char operator- ( const Zbyte& a, const Zbyte& b );
unsigned char operator* ( const Zbyte& a, const Zbyte& b );
unsigned char operator/ ( const Zbyte& a, const Zbyte& b );
unsigned char operator+ ( Zbyte a, Zbyte b );
unsigned char operator- ( Zbyte a, Zbyte b );
unsigned char operator* ( Zbyte a, Zbyte b );
unsigned char operator/ ( Zbyte a, Zbyte b );
// Casted unsigned int operations
unsigned char operator+ ( const Zbyte& a, unsigned char b );
unsigned char operator- ( const Zbyte& a, unsigned char b );
unsigned char operator* ( const Zbyte& a, unsigned char b );
unsigned char operator/ ( const Zbyte& a, unsigned char b );
unsigned char operator+ ( unsigned char b, const Zbyte& a );
unsigned char operator- ( unsigned char b, const Zbyte& a );
unsigned char operator* ( unsigned char b, const Zbyte& a );
unsigned char operator/ ( unsigned char b, const Zbyte& a );
// Casted int operations
unsigned char operator+ ( const Zbyte& a, int b );
unsigned char operator- ( const Zbyte& a, int b );
unsigned char operator* ( const Zbyte& a, int b );
unsigned char operator/ ( const Zbyte& a, int b );
unsigned char operator+ ( int b, const Zbyte& a );
unsigned char operator- ( int b, const Zbyte& a );
unsigned char operator* ( int b, const Zbyte& a );
unsigned char operator/ ( int b, const Zbyte& a );
// Float operations (leans toward float precision)
unsigned char operator+ ( const Zbyte& a, float b );
unsigned char operator- ( const Zbyte& a, float b );
unsigned char operator* ( const Zbyte& a, float b );
unsigned char operator/ ( const Zbyte& a, float b );
unsigned char operator+ ( float b, const Zbyte& a );
unsigned char operator- ( float b, const Zbyte& a );
unsigned char operator* ( float b, const Zbyte& a );
unsigned char operator/ ( float b, const Zbyte& a );
// Casted double operations (leans toward double precision)
unsigned char operator+ ( const Zbyte& a, double b );
unsigned char operator- ( const Zbyte& a, double b );
unsigned char operator* ( const Zbyte& a, double b );
unsigned char operator/ ( const Zbyte& a, double b );
unsigned char operator+ ( double b, const Zbyte& a );
unsigned char operator- ( double b, const Zbyte& a );
unsigned char operator* ( double b, const Zbyte& a );
unsigned char operator/ ( double b, const Zbyte& a );
// Boolean operations
bool operator>= ( const Zbyte& a, const Zbyte& b );
bool operator>= ( const Zbyte& a, int b );
bool operator>= ( const Zbyte& a, float b );
bool operator>= ( const Zbyte& a, double b );
bool operator>= ( int a, const Zbyte& b );
bool operator>= ( float a, const Zbyte& b );
bool operator>= ( double a, const Zbyte& b );
bool operator== ( const Zbyte& a, const Zbyte& b );
bool operator== ( const Zbyte& a, int b );
bool operator== ( const Zbyte& a, float b );
bool operator== ( const Zbyte& a, double b );
bool operator== ( int a, const Zbyte& b );
bool operator== ( float a, const Zbyte& b );
bool operator== ( double a, const Zbyte& b );
bool operator!= ( const Zbyte& a, const Zbyte& b );
bool operator!= ( const Zbyte& a, int b );
bool operator!= ( const Zbyte& a, float b );
bool operator!= ( const Zbyte& a, double b );
bool operator!= ( int a, const Zbyte& b );
bool operator!= ( float a, const Zbyte& b );
bool operator!= ( double a, const Zbyte& b );
bool operator<= ( const Zbyte& a, const Zbyte& b );
bool operator<= ( const Zbyte& a, int b );
bool operator<= ( const Zbyte& a, float b );
bool operator<= ( const Zbyte& a, double b );
bool operator<= ( int a, const Zbyte& b );
bool operator<= ( float a, const Zbyte& b );
bool operator<= ( double a, const Zbyte& b );
bool operator> ( const Zbyte& a, const Zbyte& b );
bool operator> ( const Zbyte& a, int b );
bool operator> ( const Zbyte& a, float b );
bool operator> ( const Zbyte& a, double b );
bool operator> ( int a, const Zbyte& b );
bool operator> ( float a, const Zbyte& b );
bool operator> ( double a, const Zbyte& b );
bool operator< ( const Zbyte& a, const Zbyte& b );
bool operator< ( const Zbyte& a, int b );
bool operator< ( const Zbyte& a, float b );
bool operator< ( const Zbyte& a, double b );
bool operator< ( int a, const Zbyte& b );
bool operator< ( float a, const Zbyte& b );
bool operator< ( double a, const Zbyte& b );
/// Zbyte ///////////////////////////////////////////////////////////////////////////////////////// end
/// Zushort ////////////////////////////////////////////////////////////////////////////////////////// start
class Zushort {
public:
unsigned short value;
Zushort() { value=0; }
Zushort( unsigned short value ) { this->value=value; }
operator unsigned short *() { return &value; }
Zushort *operator()() { return this; }
unsigned short operator()( unsigned short z ) { return value=(unsigned short)z; }
unsigned short operator()( unsigned char b ) { return value=(unsigned short)b; }
unsigned short operator()( unsigned int i ) { return value=(unsigned short)i; }
unsigned short operator()( int i ) { return value=(unsigned short) i; }
unsigned short operator()( float f ) { return value=(unsigned short) f; }
unsigned short operator()( double d ) { return value=(unsigned short) d; }
unsigned short operator()( Zuint &i );
unsigned short operator()( Zint &i );
unsigned short operator()( Zfloat &f );
unsigned short operator()( Zdouble &d );
Zushort& operator= ( const unsigned short z ) { value=z; return *this; }
Zushort& operator= ( const unsigned char b ) { value=(unsigned short)b; return *this; }
Zushort& operator= ( const int i ) { value=(unsigned short)i; return *this; }
Zushort& operator= ( const float f ) { value=(unsigned short)f; return *this; }
Zushort& operator= ( const double d ) { value=(unsigned short) d; return *this; }
Zushort& operator= ( const Zushort& i ) { value=i.value; return *this; }
Zushort& operator= ( const Zbyte& i ) { value=(unsigned short)i.value; return *this; }
Zushort& operator= ( const Zuint& i );
Zushort& operator= ( const Zint& i );
Zushort& operator= ( const Zfloat& f );
Zushort& operator= ( const Zdouble& d );
Zushort& operator= ( const std::string& s );
Zushort& operator+= ( const unsigned char i ) { value+=(unsigned short)i; return *this; }
Zushort& operator-= ( const unsigned char i ) { value-=(unsigned short)i; return *this; }
Zushort& operator*= ( const unsigned char i ) { value*=(unsigned short)i; return *this; }
Zushort& operator/= ( const unsigned char i ) { value/=(unsigned short)i; return *this; }
Zushort& operator+= ( const unsigned short i ) { value+=(unsigned short)i; return *this; }
Zushort& operator-= ( const unsigned short i ) { value-=(unsigned short)i; return *this; }
Zushort& operator*= ( const unsigned short i ) { value*=(unsigned short)i; return *this; }
Zushort& operator/= ( const unsigned short i ) { value/=(unsigned short)i; return *this; }
Zushort& operator+= ( const int i ) { value+=(unsigned short)i; return *this; }
Zushort& operator-= ( const int i ) { value-=(unsigned short)i; return *this; }
Zushort& operator*= ( const int i ) { value*=(unsigned short)i; return *this; }
Zushort& operator/= ( const int i ) { value/=(unsigned short)i; return *this; }
Zushort& operator+= ( const unsigned int i ) { value+=(unsigned short)i; return *this; }
Zushort& operator-= ( const unsigned int i ) { value-=(unsigned short)i; return *this; }
Zushort& operator*= ( const unsigned int i ) { value*=(unsigned short)i; return *this; }
Zushort& operator/= ( const unsigned int i ) { value/=(unsigned short)i; return *this; }
Zushort& operator+= ( const float i ) { value+=(unsigned short)i; return *this; }
Zushort& operator-= ( const float i ) { value-=(unsigned short)i; return *this; }
Zushort& operator*= ( const float i ) { value*=(unsigned short)i; return *this; }
Zushort& operator/= ( const float i ) { value/=(unsigned short)i; return *this; }
Zushort& operator+= ( const double i ) { value+=(unsigned short)i; return *this; }
Zushort& operator-= ( const double i ) { value-=(unsigned short)i; return *this; }
Zushort& operator*= ( const double i ) { value*=(unsigned short)i; return *this; }
Zushort& operator/= ( const double i ) { value/=(unsigned short)i; return *this; }
Zushort& operator++ (int) { value+=1; return *this; }
Zushort& operator-- (int) { value-=1; return *this; }
operator unsigned short() { return value; }
operator int() { return -(int)value; }
bool operator !() { return ( value == 0 ); }
// Not used intentionally to create warning:
// operator float() { return (float)value; }
// operator double() { return (double)value; }
// Causes ambiguity, because this is removed, the resulting issue (no better solution, see C2593)
// (mixed type comparisons require explicit casts) is described in the test:
// operator float() { return (float) value; }
// operator float() { return (double) value; }
};
unsigned short operator+ ( const Zushort& a, const Zushort& b );
unsigned short operator- ( const Zushort& a, const Zushort& b );
unsigned short operator* ( const Zushort& a, const Zushort& b );
unsigned short operator/ ( const Zushort& a, const Zushort& b );
unsigned short operator+ ( Zushort a, Zushort b );
unsigned short operator- ( Zushort a, Zushort b );
unsigned short operator* ( Zushort a, Zushort b );
unsigned short operator/ ( Zushort a, Zushort b );
// Casted unsigned int operations
unsigned short operator+ ( const Zushort& a, unsigned char b );
unsigned short operator- ( const Zushort& a, unsigned char b );
unsigned short operator* ( const Zushort& a, unsigned char b );
unsigned short operator/ ( const Zushort& a, unsigned char b );
unsigned short operator+ ( unsigned char b, const Zushort& a );
unsigned short operator- ( unsigned char b, const Zushort& a );
unsigned short operator* ( unsigned char b, const Zushort& a );
unsigned short operator/ ( unsigned char b, const Zushort& a );
// Casted int operations
unsigned short operator+ ( const Zushort& a, int b );
unsigned short operator- ( const Zushort& a, int b );
unsigned short operator* ( const Zushort& a, int b );
unsigned short operator/ ( const Zushort& a, int b );
unsigned short operator+ ( int b, const Zushort& a );
unsigned short operator- ( int b, const Zushort& a );
unsigned short operator* ( int b, const Zushort& a );
unsigned short operator/ ( int b, const Zushort& a );
// Float operations (leans toward float precision)
unsigned short operator+ ( const Zushort& a, float b );
unsigned short operator- ( const Zushort& a, float b );
unsigned short operator* ( const Zushort& a, float b );
unsigned short operator/ ( const Zushort& a, float b );
unsigned short operator+ ( float b, const Zushort& a );
unsigned short operator- ( float b, const Zushort& a );
unsigned short operator* ( float b, const Zushort& a );
unsigned short operator/ ( float b, const Zushort& a );
// Casted double operations (leans toward double precision)
unsigned short operator+ ( const Zushort& a, double b );
unsigned short operator- ( const Zushort& a, double b );
unsigned short operator* ( const Zushort& a, double b );
unsigned short operator/ ( const Zushort& a, double b );
unsigned short operator+ ( double b, const Zushort& a );
unsigned short operator- ( double b, const Zushort& a );
unsigned short operator* ( double b, const Zushort& a );
unsigned short operator/ ( double b, const Zushort& a );
/// Zbyte ///////////////////////////////////////////////////////////////////////////////////////// end
/// Zint ////////////////////////////////////////////////////////////////////////////////////////// start
class Zint {
public:
int value;
Zint() { value=0; }
Zint( int value ) { this->value=value; }
int abs() { return value < 0 ? -value : value; } // Macos does not define abs(int)
std::string toString() { return std::to_string(value); }
operator std::string() { return toString(); }
operator int() { return value; }
operator int *() { return &value; }
Zint *operator()() { return this; }
int operator()( int i ) { return value=i; }
int operator()( float f ) { return value=(int)f; }
int operator()( double d ) { return value=(int)d; }
int operator()( Zbyte &i );
int operator()( Zuint &i );
int operator()( Zint &i ) { return value=i.value; }
int operator()( Zfloat &f );
int operator()( Zdouble &d );
Zint& operator= ( const int i ) { value=i; return *this; }
Zint& operator= ( const float f ) { value=(int)f; return *this; }
Zint& operator= ( const double d ) { value=(int) d; return *this; }
Zint& operator= ( const Zint& i ) { value=i.value; return *this; }
Zint& operator= ( const Zbyte& b );
Zint& operator= ( const Zuint& i );
Zint& operator= ( const Zfloat& f );
Zint& operator= ( const Zdouble& d );
Zint& operator= ( const std::string& s );
Zint& operator+= ( const Zint& i ) { value+=i.value; return *this; }
Zint& operator-= ( const Zint& i ) { value-=i.value; return *this; }
Zint& operator*= ( const Zint& i ) { value*=i.value; return *this; }
Zint& operator/= ( const Zint& i ) { value/=i.value; return *this; }
Zint& operator+= ( const Zfloat& f );
Zint& operator-= ( const Zfloat& f );
Zint& operator*= ( const Zfloat& f );
Zint& operator/= ( const Zfloat& f );
Zint& operator+= ( const unsigned char i ) { value+=(int)i; return *this; }
Zint& operator-= ( const unsigned char i ) { value-=(int)i; return *this; }
Zint& operator*= ( const unsigned char i ) { value*=(int)i; return *this; }
Zint& operator/= ( const unsigned char i ) { value/=(int)i; return *this; }
Zint& operator+= ( const unsigned short i ) { value+=(int)i; return *this; }
Zint& operator-= ( const unsigned short i ) { value-=(int)i; return *this; }
Zint& operator*= ( const unsigned short i ) { value*=(int)i; return *this; }
Zint& operator/= ( const unsigned short i ) { value/=(int)i; return *this; }
Zint& operator+= ( const int i ) { value+=i; return *this; }
Zint& operator-= ( const int i ) { value-=i; return *this; }
Zint& operator*= ( const int i ) { value*=i; return *this; }
Zint& operator/= ( const int i ) { value/=i; return *this; }
Zint& operator+= ( const unsigned int i ) { value+=(int)i; return *this; }
Zint& operator-= ( const unsigned int i ) { value-=(int)i; return *this; }
Zint& operator*= ( const unsigned int i ) { value*=(int)i; return *this; }
Zint& operator/= ( const unsigned int i ) { value/=(int)i; return *this; }
Zint& operator+= ( const float i ) { value+=(int)i; return *this; }
Zint& operator-= ( const float i ) { value-=(int)i; return *this; }
Zint& operator*= ( const float i ) { value*=(int)i; return *this; }
Zint& operator/= ( const float i ) { value/=(int)i; return *this; }
Zint& operator+= ( const double i ) { value+=(int)i; return *this; }
Zint& operator-= ( const double i ) { value-=(int)i; return *this; }
Zint& operator*= ( const double i ) { value*=(int)i; return *this; }
Zint& operator/= ( const double i ) { value/=(int)i; return *this; }
Zint& operator++ (int) { value+=1; return *this; }
Zint& operator-- (int) { value-=1; return *this; }
const int operator-() { return -value; }
// operator size_t() { return (size_t)value; }
operator unsigned int() { return (unsigned int) value; }
operator float() { return (float) value; }
operator double() { return (double) value; }
bool operator !() { return ( value == 0 ); }
// Not used intentionally to create warning:
// operator float() { return (float)value; }
// operator double() { return (double)value; }
// Causes ambiguity, because this is removed, the resulting issue (no better solution, see C2593)
// (mixed type comparisons require explicit casts) is described in the test:
// operator float() { return (float) value; }
// operator float() { return (double) value; }
};
int operator+ ( const Zint& a, const Zint& b );
int operator- ( const Zint& a, const Zint& b );
int operator* ( const Zint& a, const Zint& b );
int operator/ ( const Zint& a, const Zint& b );
/* Creates C2593 for some reason...
int operator+ ( Zint a, Zint b );
int operator- ( Zint a, Zint b );
int operator* ( Zint a, Zint b );
int operator/ ( Zint a, Zint b );
*/
// Casted int operations
int operator+ ( const Zint& a, int b );
int operator- ( const Zint& a, int b );
int operator* ( const Zint& a, int b );
int operator/ ( const Zint& a, int b );
int operator% ( const Zint& a, int b );
int operator+ ( int b, const Zint& a );
int operator- ( int b, const Zint& a );
int operator* ( int b, const Zint& a );
int operator/ ( int b, const Zint& a );
int operator% ( int b, const Zint& a );
// Float operations (leans toward float precision)
int operator+ ( const Zint& a, float b );
int operator- ( const Zint& a, float b );
int operator* ( const Zint& a, float b );
int operator/ ( const Zint& a, float b );
int operator+ ( float b, const Zint& a );
int operator- ( float b, const Zint& a );
int operator* ( float b, const Zint& a );
int operator/ ( float b, const Zint& a );
// Casted double operations (leans toward double precision)
int operator+ ( const Zint& a, double b );
int operator- ( const Zint& a, double b );
int operator* ( const Zint& a, double b );
int operator/ ( const Zint& a, double b );
int operator+ ( double b, const Zint& a );
int operator- ( double b, const Zint& a );
int operator* ( double b, const Zint& a );
int operator/ ( double b, const Zint& a );
// Modulo
int operator% ( const Zint &a, const Zint &b );
// Boolean operations
bool operator>= ( const Zint& a, const Zint& b );
bool operator>= ( const Zint& a, unsigned int b );
bool operator>= ( const Zint& a, int b );
bool operator>= ( const Zint& a, float b );
bool operator>= ( const Zint& a, double b );
bool operator>= ( unsigned int a, const Zint& b );
bool operator>= ( int a, const Zint& b );
bool operator>= ( float a, const Zint& b );
bool operator>= ( double a, const Zint& b );
bool operator== ( const Zint& a, const Zbyte& b );
bool operator== ( const Zint& a, const Zushort& b );
bool operator== ( const Zint& a, const Zuint& b );
bool operator== ( const Zint& a, const Zdouble& b );
bool operator== ( const Zbyte& a, const Zint& b );
bool operator== ( const Zushort& a, const Zint& b );
bool operator== ( const Zuint& a, const Zint& b );
bool operator== ( const Zdouble& a, const Zint& b );
bool operator== ( const Zint& a, const Zint& b );
bool operator== ( const Zint& a, unsigned int b );
bool operator== ( const Zint& a, int b );
bool operator== ( const Zint& a, float b );
bool operator== ( const Zint& a, double b );
bool operator== ( unsigned int a, const Zint& b );
bool operator== ( int a, const Zint& b );
bool operator== ( float a, const Zint& b );
bool operator== ( double a, const Zint& b );
bool operator!= ( const Zint& a, const Zint& b );
bool operator!= ( const Zint& a, unsigned int b );
bool operator!= ( const Zint& a, int b );
bool operator!= ( const Zint& a, float b );
bool operator!= ( const Zint& a, double b );
bool operator!= ( unsigned int a, const Zint& b );
bool operator!= ( int a, const Zint& b );
bool operator!= ( float a, const Zint& b );
bool operator!= ( double a, const Zint& b );
bool operator<= ( const Zint& a, const Zint& b );
bool operator<= ( const Zint& a, unsigned int b );
bool operator<= ( const Zint& a, int b );
bool operator<= ( const Zint& a, float b );
bool operator<= ( const Zint& a, double b );
bool operator<= ( unsigned int a, const Zint& b );
bool operator<= ( int a, const Zint& b );
bool operator<= ( float a, const Zint& b );
bool operator<= ( double a, const Zint& b );
bool operator> ( const Zint& a, const Zint& b );
bool operator> ( const Zint& a, unsigned int b );
bool operator> ( const Zint& a, int b );
bool operator> ( const Zint& a, float b );
bool operator> ( const Zint& a, double b );
bool operator> ( unsigned int a, const Zint& b );
bool operator> ( int a, const Zint& b );
bool operator> ( float a, const Zint& b );
bool operator> ( double a, const Zint& b );
bool operator< ( const Zint& a, const Zint& b );
bool operator< ( const Zint& a, unsigned int b );
bool operator< ( const Zint& a, int b );
bool operator< ( const Zint& a, float b );
bool operator< ( const Zint& a, double b );
bool operator< ( unsigned int a, const Zint& b );
bool operator< ( int a, const Zint& b );
bool operator< ( float a, const Zint& b );
bool operator< ( double a, const Zint& b );
/// Zint ////////////////////////////////////////////////////////////////////////////////////////// end
/// Zuint ////////////////////////////////////////////////////////////////////////////////////////// start
enum Zuint_bits {
Zuint_0 =0x1,
Zuint_1 =0x2,
Zuint_2 =0x4,
Zuint_3 =0x8,
Zuint_4 =0x10,
Zuint_5 =0x20,
Zuint_6 =0x40,
Zuint_7 =0x80,
Zuint_8 =0x100,
Zuint_9 =0x200,
Zuint_10=0x400,
Zuint_11=0x800,
Zuint_12=0x1000,
Zuint_13=0x2000,
Zuint_14=0x4000,
Zuint_15=0x8000,
Zuint_16=0x10000,
Zuint_17=0x20000,
Zuint_18=0x40000,
Zuint_19=0x80000,
Zuint_20=0x100000,
Zuint_21=0x200000,
Zuint_22=0x400000,
Zuint_23=0x800000,
Zuint_24=0x1000000,
Zuint_25=0x2000000,
Zuint_26=0x4000000,
Zuint_27=0x8000000,
Zuint_28=0x10000000,
Zuint_29=0x20000000,
Zuint_30=0x40000000,
Zuint_31=0x80000000
};
class Zuint {
public:
unsigned int value;
Zuint() { value=0; }
Zuint( unsigned int value ) { this->value=value; }
std::string toString() { return std::to_string(value); }
operator std::string() { return toString(); }
operator unsigned int() { return value; }
operator unsigned int *() { return &value; }
Zuint *operator()() { return this; }
unsigned int operator()( unsigned int i ) { return value=i; }
unsigned int operator()( int i ) { return value=(unsigned int) i; }
unsigned int operator()( float f ) { return value=(unsigned int)f; }
unsigned int operator()( double d ) { return value=(unsigned int)d; }
unsigned int operator()( Zbyte &i );
unsigned int operator()( Zuint &i ) { return i.value; }
unsigned int operator()( Zint &i );
unsigned int operator()( Zfloat &f );
unsigned int operator()( Zdouble &d );
bool isOn( unsigned int bitwise_flag ) {
return ( value & bitwise_flag ) > 0;
}
bool isOff( unsigned int bitwise_flag ) { return !isOn(bitwise_flag); }
void Toggle( unsigned int bitwise_flag, bool on ) {
if ( on ) value = value | bitwise_flag;
else value = value & ~bitwise_flag;
}
Zuint& operator= ( const unsigned int i ) { value=i; return *this; }
Zuint& operator= ( const int i ) { value=i; return *this; }
Zuint& operator= ( const float f ) { value=(int)f; return *this; }
Zuint& operator= ( const double d ) { value=(int) d; return *this; }
Zuint& operator= ( const Zuint& i ) { value=i.value; return *this; }
Zuint& operator= ( const Zbyte& b );
Zuint& operator= ( const Zint& i );
Zuint& operator= ( const Zfloat& f );
Zuint& operator= ( const Zdouble& d );
Zuint& operator= ( const std::string& s );
Zuint& operator+= ( const Zuint& i ) { value+=i.value; return *this; }
Zuint& operator-= ( const Zuint& i ) { value-=i.value; return *this; }
Zuint& operator*= ( const Zuint& i ) { value*=i.value; return *this; }
Zuint& operator/= ( const Zuint& i ) { value/=i.value; return *this; }
Zuint& operator+= ( const Zint& i ) { value+=(unsigned int) i.value; return *this; }
Zuint& operator-= ( const Zint& i ) { value-=(unsigned int) i.value; return *this; }
Zuint& operator*= ( const Zint& i ) { value*=(unsigned int) i.value; return *this; }
Zuint& operator/= ( const Zint& i ) { value/=(unsigned int) i.value; return *this; }
Zuint& operator+= ( const unsigned char i ) { value+=(unsigned int) i; return *this; }
Zuint& operator-= ( const unsigned char i ) { value-=(unsigned int) i; return *this; }
Zuint& operator*= ( const unsigned char i ) { value*=(unsigned int) i; return *this; }
Zuint& operator/= ( const unsigned char i ) { value/=(unsigned int) i; return *this; }
Zuint& operator+= ( const unsigned short i ) { value+=(unsigned int) i; return *this; }
Zuint& operator-= ( const unsigned short i ) { value-=(unsigned int) i; return *this; }
Zuint& operator*= ( const unsigned short i ) { value*=(unsigned int) i; return *this; }
Zuint& operator/= ( const unsigned short i ) { value/=(unsigned int) i; return *this; }
Zuint& operator+= ( const int i ) { value+=(unsigned int) i; return *this; }
Zuint& operator-= ( const int i ) { value-=(unsigned int) i; return *this; }
Zuint& operator*= ( const int i ) { value*=(unsigned int) i; return *this; }
Zuint& operator/= ( const int i ) { value/=(unsigned int) i; return *this; }
Zuint& operator+= ( const unsigned int i ) { value+=i; return *this; }
Zuint& operator-= ( const unsigned int i ) { value-=i; return *this; }
Zuint& operator*= ( const unsigned int i ) { value*=i; return *this; }
Zuint& operator/= ( const unsigned int i ) { value/=i; return *this; }
Zuint& operator+= ( const float i ) { value+=(unsigned int) i; return *this; }
Zuint& operator-= ( const float i ) { value-=(unsigned int) i; return *this; }
Zuint& operator*= ( const float i ) { value*=(unsigned int) i; return *this; }
Zuint& operator/= ( const float i ) { value/=(unsigned int) i; return *this; }
Zuint& operator+= ( const double i ) { value+=(unsigned int) i; return *this; }
Zuint& operator-= ( const double i ) { value-=(unsigned int) i; return *this; }
Zuint& operator*= ( const double i ) { value*=(unsigned int) i; return *this; }
Zuint& operator/= ( const double i ) { value/=(unsigned int) i; return *this; }
Zuint& operator++ (int) { value+=1; return *this; }
Zuint& operator-- (int) { value-=1; return *this; }
operator int() { return (int) value; }
bool operator !() { return ( value == 0 ); }
// Not used intentionally to create warning:
// operator float() { return (float)value; }
// operator double() { return (double)value; }
// Causes ambiguity, because this is removed, the resulting issue (no better solution, see C2593)
// (mixed type comparisons require explicit casts) is described in the test:
// operator float() { return (float) value; }
// operator float() { return (double) value; }
};
bool operator< ( unsigned int a, const Zuint& b );
unsigned int operator+ ( const Zuint& a, const Zuint& b );
unsigned int operator- ( const Zuint& a, const Zuint& b );
unsigned int operator* ( const Zuint& a, const Zuint& b );
unsigned int operator/ ( const Zuint& a, const Zuint& b );
// Casted unsigned int operations
unsigned int operator+ ( const Zuint& a, int b );
unsigned int operator- ( const Zuint& a, int b );
unsigned int operator* ( const Zuint& a, int b );
unsigned int operator/ ( const Zuint& a, int b );
unsigned int operator+ ( int b, const Zuint& a );
unsigned int operator- ( int b, const Zuint& a );
unsigned int operator* ( int b, const Zuint& a );
unsigned int operator/ ( int b, const Zuint& a );
// Casted int operations
unsigned int operator+ ( const Zuint& a, int b );
unsigned int operator- ( const Zuint& a, int b );
unsigned int operator* ( const Zuint& a, int b );
unsigned int operator/ ( const Zuint& a, int b );
unsigned int operator+ ( int b, const Zuint& a );
unsigned int operator- ( int b, const Zuint& a );
unsigned int operator* ( int b, const Zuint& a );
unsigned int operator/ ( int b, const Zuint& a );
// Float operations (leans toward float precision)
unsigned int operator+ ( const Zuint& a, float b );
unsigned int operator- ( const Zuint& a, float b );
unsigned int operator* ( const Zuint& a, float b );
unsigned int operator/ ( const Zuint& a, float b );
unsigned int operator+ ( float b, const Zuint& a );
unsigned int operator- ( float b, const Zuint& a );
unsigned int operator* ( float b, const Zuint& a );
unsigned int operator/ ( float b, const Zuint& a );
// Casted double operations (leans toward double precision)
unsigned int operator+ ( const Zuint& a, double b );
unsigned int operator- ( const Zuint& a, double b );
unsigned int operator* ( const Zuint& a, double b );
unsigned int operator/ ( const Zuint& a, double b );
unsigned int operator+ ( double b, const Zuint& a );
unsigned int operator- ( double b, const Zuint& a );
unsigned int operator* ( double b, const Zuint& a );
unsigned int operator/ ( double b, const Zuint& a );
/// Zuint ////////////////////////////////////////////////////////////////////////////////////////// end
/// Zdouble ////////////////////////////////////////////////////////////////////////////////////////// start