Embedded Template Library
1.0
Loading...
Searching...
No Matches
type_def.h
Go to the documentation of this file.
1
2
3
/******************************************************************************
4
The MIT License(MIT)
5
6
Embedded Template Library.
7
https://github.com/ETLCPP/etl
8
https://www.etlcpp.com
9
10
Copyright(c) 2016 John Wellbelove
11
12
Permission is hereby granted, free of charge, to any person obtaining a copy
13
of this software and associated documentation files(the "Software"), to deal
14
in the Software without restriction, including without limitation the rights
15
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16
copies of the Software, and to permit persons to whom the Software is
17
furnished to do so, subject to the following conditions :
18
19
The above copyright notice and this permission notice shall be included in all
20
copies or substantial portions of the Software.
21
22
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
SOFTWARE.
29
******************************************************************************/
30
31
#ifndef ETL_TYPE_DEF_INCLUDED
32
#define ETL_TYPE_DEF_INCLUDED
33
34
#include "
platform.h
"
35
#include "
type_traits.h
"
36
37
namespace
etl
38
{
39
#define ETL_TYPEDEF(T, name) class name##_tag; typedef etl::type_def<name##_tag, T> name
40
#define ETL_USING(name, T) class name##_tag; typedef etl::type_def<name##_tag, T> name
41
42
//*************************************************************************
55
//*************************************************************************
56
template
<
typename
TIdType,
typename
TValue>
57
class
type_def
58
{
59
public
:
60
61
typedef
TValue
type;
62
typedef
TValue
value_type;
63
typedef
TIdType
id_type;
64
65
//*********************************************************************
66
ETL_CONSTEXPR
type_def
() ETL_NOEXCEPT
67
: value(
TValue
())
68
{
69
}
70
71
//*********************************************************************
72
#if ETL_USING_CPP11
73
template <typename T, typename = typename etl::enable_if<etl::is_convertible<T, TValue>::value
,
void
>::type>
74
#else
75
template
<
typename
T>
76
#endif
77
ETL_CONSTEXPR
type_def
(
T
value_
) ETL_NOEXCEPT
78
: value(
value_
)
79
{
80
}
81
82
//*********************************************************************
83
#if ETL_USING_CPP11
84
ETL_CONSTEXPR
type_def
(
const
type_def
&
other
) =
default
;
85
#endif
86
87
//*********************************************************************
88
ETL_CONSTEXPR
operator
TValue
()
const
ETL_NOEXCEPT
89
{
90
return
value;
91
}
92
93
//*********************************************************************
94
ETL_CONSTEXPR14
type_def
& operator ++() ETL_NOEXCEPT
95
{
96
++value;
97
return
*
this
;
98
}
99
100
//*********************************************************************
101
ETL_CONSTEXPR14
type_def
operator ++(
int
) ETL_NOEXCEPT
102
{
103
type_def
temp
(*
this
);
104
type_def::operator ++();
105
return
temp
;
106
}
107
108
//*********************************************************************
109
ETL_CONSTEXPR14
type_def
& operator --() ETL_NOEXCEPT
110
{
111
--value;
112
return
*
this
;
113
}
114
115
//*********************************************************************
116
ETL_CONSTEXPR14
type_def
operator --(
int
) ETL_NOEXCEPT
117
{
118
type_def
temp
(*
this
);
119
type_def::operator --();
120
return
temp
;
121
}
122
123
//*********************************************************************
124
template
<
typename
T>
125
ETL_CONSTEXPR14
126
#if ETL_USING_CPP11
127
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
128
#else
129
type_def
&
130
#endif
131
operator +=(
T
rhs
) ETL_NOEXCEPT
132
{
133
value +=
rhs
;
134
return
*
this
;
135
}
136
137
//*********************************************************************
138
ETL_CONSTEXPR14
139
type_def
& operator +=(
const
type_def
&
rhs
) ETL_NOEXCEPT
140
{
141
value +=
rhs
.value;
142
return
*
this
;
143
}
144
145
//*********************************************************************
146
template
<
typename
T>
147
ETL_CONSTEXPR14
148
#if ETL_USING_CPP11
149
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
150
#else
151
type_def
&
152
#endif
153
operator -=(
T
rhs
) ETL_NOEXCEPT
154
{
155
value -=
rhs
;
156
return
*
this
;
157
}
158
159
//*********************************************************************
160
ETL_CONSTEXPR14
type_def
& operator -=(
const
type_def
&
rhs
) ETL_NOEXCEPT
161
{
162
value -=
rhs
.value;
163
return
*
this
;
164
}
165
166
//*********************************************************************
167
template
<
typename
T>
168
ETL_CONSTEXPR14
169
#if ETL_USING_CPP11
170
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
171
#else
172
type_def
&
173
#endif
174
operator *=(
T
rhs
) ETL_NOEXCEPT
175
{
176
value *=
rhs
;
177
return
*
this
;
178
}
179
180
//*********************************************************************
181
ETL_CONSTEXPR14
type_def
& operator *=(
const
type_def
&
rhs
) ETL_NOEXCEPT
182
{
183
value *=
rhs
.value;
184
return
*
this
;
185
}
186
187
//*********************************************************************
188
template
<
typename
T>
189
ETL_CONSTEXPR14
190
#if ETL_USING_CPP11
191
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
192
#else
193
type_def
&
194
#endif
195
operator /=(
T
rhs
) ETL_NOEXCEPT
196
{
197
value /=
rhs
;
198
return
*
this
;
199
}
200
201
//*********************************************************************
202
ETL_CONSTEXPR14
type_def
& operator /=(
const
type_def
&
rhs
) ETL_NOEXCEPT
203
{
204
value /=
rhs
.value;
205
return
*
this
;
206
}
207
208
//*********************************************************************
209
template
<
typename
T>
210
ETL_CONSTEXPR14
211
#if ETL_USING_CPP11
212
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
213
#else
214
type_def
&
215
#endif
216
operator %=(
T
rhs
) ETL_NOEXCEPT
217
{
218
value %=
rhs
;
219
return
*
this
;
220
}
221
222
//*********************************************************************
223
ETL_CONSTEXPR14
type_def
& operator %=(
const
type_def
&
rhs
) ETL_NOEXCEPT
224
{
225
value %=
rhs
.value;
226
return
*
this
;
227
}
228
229
//*********************************************************************
230
template
<
typename
T>
231
ETL_CONSTEXPR14
232
#if ETL_USING_CPP11
233
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
234
#else
235
type_def
&
236
#endif
237
operator &=(
T
rhs
) ETL_NOEXCEPT
238
{
239
value &=
rhs
;
240
return
*
this
;
241
}
242
243
//*********************************************************************
244
ETL_CONSTEXPR14
type_def
& operator &=(
const
type_def
&
rhs
) ETL_NOEXCEPT
245
{
246
value &=
rhs
.value;
247
return
*
this
;
248
}
249
250
//*********************************************************************
251
template
<
typename
T>
252
ETL_CONSTEXPR14
253
#if ETL_USING_CPP11
254
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
255
#else
256
type_def
&
257
#endif
258
operator |=(
T
rhs
) ETL_NOEXCEPT
259
{
260
value |=
rhs
;
261
return
*
this
;
262
}
263
264
//*********************************************************************
265
ETL_CONSTEXPR14
type_def
& operator |=(
const
type_def
&
rhs
) ETL_NOEXCEPT
266
{
267
value |=
rhs
.value;
268
return
*
this
;
269
}
270
271
//*********************************************************************
272
template
<
typename
T>
273
ETL_CONSTEXPR14
274
#if ETL_USING_CPP11
275
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
&>::type
276
#else
277
type_def
&
278
#endif
279
operator ^=(
T
rhs
) ETL_NOEXCEPT
280
{
281
value ^=
rhs
;
282
return
*
this
;
283
}
284
285
//*********************************************************************
286
ETL_CONSTEXPR14
type_def
& operator ^=(
const
type_def
&
rhs
) ETL_NOEXCEPT
287
{
288
value ^=
rhs
.value;
289
return
*
this
;
290
}
291
292
//*********************************************************************
293
template
<
typename
T>
294
ETL_CONSTEXPR14
typename
etl::enable_if<etl::is_integral<T>::value
,
type_def
&>::type
295
operator <<=(
T
rhs
) ETL_NOEXCEPT
296
{
297
value <<=
rhs
;
298
return
*
this
;
299
}
300
301
//*********************************************************************
302
template
<
typename
T>
303
ETL_CONSTEXPR14
typename
etl::enable_if<etl::is_integral<T>::value
,
type_def
&>::type
304
operator >>=(
T
rhs
) ETL_NOEXCEPT
305
{
306
value >>=
rhs
;
307
return
*
this
;
308
}
309
310
//*********************************************************************
311
#if ETL_USING_CPP11
312
ETL_CONSTEXPR14
type_def
& operator =(
const
type_def
&
rhs
) =
default
;
313
#endif
314
315
//*********************************************************************
316
TValue
& get() ETL_NOEXCEPT
317
{
318
return
value;
319
}
320
321
//*********************************************************************
322
ETL_CONSTEXPR
const
TValue
& get()
const
ETL_NOEXCEPT
323
{
324
return
value;
325
}
326
327
//*********************************************************************
328
// + operator
329
//*********************************************************************
330
template
<
typename
T>
331
friend
ETL_CONSTEXPR
332
#if ETL_USING_CPP11
333
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
334
#else
335
type_def
336
#endif
337
operator +(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
338
{
339
return
type_def
(
lhs
.value +
rhs
);
340
}
341
342
//*********************************************************************
343
template
<
typename
T>
344
friend
ETL_CONSTEXPR
type_def
operator +(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
345
{
346
return
type_def
(
lhs
+
rhs
.value);
347
}
348
349
//*********************************************************************
350
friend
ETL_CONSTEXPR
type_def
operator +(
const
type_def
&
lhs
,
const
type_def
&
rhs
)
351
{
352
return
type_def
(
lhs
.value +
rhs
.value);
353
}
354
355
//*********************************************************************
356
// - operator
357
//*********************************************************************
358
template
<
typename
T>
359
friend
ETL_CONSTEXPR
360
#if ETL_USING_CPP11
361
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
362
#else
363
type_def
364
#endif
365
operator -(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
366
{
367
return
type_def
(
lhs
.value -
rhs
);
368
}
369
370
//*********************************************************************
371
template
<
typename
T>
372
friend
ETL_CONSTEXPR
373
#if ETL_USING_CPP11
374
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
375
#else
376
type_def
377
#endif
378
operator -(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
379
{
380
return
type_def
(
lhs
-
rhs
.value);
381
}
382
383
//*********************************************************************
384
friend
ETL_CONSTEXPR
type_def
operator -(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
385
{
386
return
type_def
(
lhs
.value -
rhs
.value);
387
}
388
389
//*********************************************************************
390
// * operator
391
//*********************************************************************
392
template
<
typename
T>
393
friend
ETL_CONSTEXPR
394
#if ETL_USING_CPP11
395
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
396
#else
397
type_def
398
#endif
399
operator *(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
400
{
401
return
type_def
(
lhs
.value *
rhs
);
402
}
403
404
//*********************************************************************
405
template
<
typename
T>
406
friend
ETL_CONSTEXPR
407
#if ETL_USING_CPP11
408
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
409
#else
410
type_def
411
#endif
412
operator *(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
413
{
414
return
type_def
(
lhs
*
rhs
.value);
415
}
416
417
//*********************************************************************
418
friend
ETL_CONSTEXPR
type_def
operator *(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
419
{
420
return
type_def
(
lhs
.value *
rhs
.value);
421
}
422
423
//*********************************************************************
424
// / operator
425
//*********************************************************************
426
template
<
typename
T>
427
friend
ETL_CONSTEXPR
428
#if ETL_USING_CPP11
429
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
430
#else
431
type_def
432
#endif
433
operator /(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
434
{
435
return
type_def
(
lhs
.value /
rhs
);
436
}
437
438
//*********************************************************************
439
template
<
typename
T>
440
friend
ETL_CONSTEXPR
441
#if ETL_USING_CPP11
442
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
443
#else
444
type_def
445
#endif
446
operator /(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
447
{
448
return
type_def
(
lhs
/
rhs
.value);
449
}
450
451
//*********************************************************************
452
friend
ETL_CONSTEXPR
type_def
operator /(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
453
{
454
return
type_def
(
lhs
.value /
rhs
.value);
455
}
456
457
//*********************************************************************
458
template
<
typename
T>
459
friend
ETL_CONSTEXPR
460
#if ETL_USING_CPP11
461
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
462
#else
463
type_def
464
#endif
465
operator %(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
466
{
467
return
type_def
(
lhs
.value %
rhs
);
468
}
469
470
//*********************************************************************
471
// % operator
472
//*********************************************************************
473
template
<
typename
T>
474
friend
ETL_CONSTEXPR
475
#if ETL_USING_CPP11
476
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
477
#else
478
type_def
479
#endif
480
operator %(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
481
{
482
return
type_def
(
lhs
%
rhs
.value);
483
}
484
485
//*********************************************************************
486
friend
ETL_CONSTEXPR
type_def
operator %(
const
type_def
&
lhs
,
const
type_def
&
rhs
)
487
{
488
return
type_def
(
lhs
.value %
rhs
.value);
489
}
490
491
//*********************************************************************
492
// & operator
493
//*********************************************************************
494
template
<
typename
T>
495
friend
ETL_CONSTEXPR
496
#if ETL_USING_CPP11
497
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
498
#else
499
type_def
500
#endif
501
operator &(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
502
{
503
return
type_def
(
lhs
.value &
rhs
);
504
}
505
506
//*********************************************************************
507
template
<
typename
T>
508
friend
ETL_CONSTEXPR
509
#if ETL_USING_CPP11
510
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
511
#else
512
type_def
513
#endif
514
operator &(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
515
{
516
return
type_def
(
lhs
&
rhs
.value);
517
}
518
519
//*********************************************************************
520
friend
ETL_CONSTEXPR
type_def
operator &(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
521
{
522
return
type_def
(
lhs
.value &
rhs
.value);
523
}
524
525
//*********************************************************************
526
// | operator
527
//*********************************************************************
528
template
<
typename
T>
529
friend
ETL_CONSTEXPR
530
#if ETL_USING_CPP11
531
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
532
#else
533
type_def
534
#endif
535
operator |(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
536
{
537
return
type_def
(
lhs
.value |
rhs
);
538
}
539
540
//*********************************************************************
541
template
<
typename
T>
542
friend
ETL_CONSTEXPR
543
#if ETL_USING_CPP11
544
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
545
#else
546
type_def
547
#endif
548
operator |(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
549
{
550
return
type_def
(
lhs
|
rhs
.value);
551
}
552
553
//*********************************************************************
554
friend
ETL_CONSTEXPR
type_def
operator |(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
555
{
556
return
type_def
(
lhs
.value |
rhs
.value);
557
}
558
559
//*********************************************************************
560
// ^ operator
561
//*********************************************************************
562
template
<
typename
T>
563
friend
ETL_CONSTEXPR
564
#if ETL_USING_CPP11
565
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
566
#else
567
type_def
568
#endif
569
operator ^(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
570
{
571
return
type_def
(
lhs
.value ^
rhs
);
572
}
573
574
//*********************************************************************
575
template
<
typename
T>
576
friend
ETL_CONSTEXPR
577
#if ETL_USING_CPP11
578
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
type_def
>::type
579
#else
580
type_def
581
#endif
582
operator ^(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
583
{
584
return
type_def
(
lhs
^
rhs
.value);
585
}
586
587
//*********************************************************************
588
friend
ETL_CONSTEXPR
type_def
operator ^(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
589
{
590
return
type_def
(
lhs
.value ^
rhs
.value);
591
}
592
593
//*********************************************************************
594
// << operator
595
//*********************************************************************
596
template
<
typename
T>
597
friend
ETL_CONSTEXPR
typename
etl::enable_if<etl::is_integral<T>::value
,
type_def
>::type
598
operator <<(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
599
{
600
return
type_def
(
lhs
.value <<
rhs
);
601
}
602
603
//*********************************************************************
604
template
<
typename
T>
605
friend
ETL_CONSTEXPR
typename
etl::enable_if
<(
etl::is_integral<T>::value
&&
etl::is_integral<TValue>::value
),
T
>::type
606
operator
<<(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
607
{
608
return
lhs
<<
rhs
.value;
609
}
610
611
//*********************************************************************
612
// >> operator
613
//*********************************************************************
614
template
<
typename
T>
615
friend
ETL_CONSTEXPR
typename
etl::enable_if<etl::is_integral<T>::value
,
type_def
>::type
616
operator >>(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
617
{
618
return
type_def
(
lhs
.value >>
rhs
);
619
}
620
621
//*********************************************************************
622
template
<
typename
T>
623
friend
ETL_CONSTEXPR
624
typename
etl::enable_if
<(
etl::is_integral<T>::value
&&
etl::is_integral<TValue>::value
),
T
>::type
625
operator
>>(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
626
{
627
return
lhs
>>
rhs
.value;
628
}
629
630
//*********************************************************************
631
// < operator
632
//*********************************************************************
633
template
<
typename
T>
634
friend
ETL_CONSTEXPR
635
#if ETL_USING_CPP11
636
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
637
#else
638
bool
639
#endif
640
operator <(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
641
{
642
return
lhs
.value <
rhs
;
643
}
644
645
//*********************************************************************
646
template
<
typename
T>
647
friend
ETL_CONSTEXPR
648
#if ETL_USING_CPP11
649
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
650
#else
651
bool
652
#endif
653
operator <(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
654
{
655
return
lhs
<
rhs
.value;
656
}
657
658
//*********************************************************************
659
friend
ETL_CONSTEXPR
bool
operator <(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
660
{
661
return
lhs
.value <
rhs
.value;
662
}
663
664
//*********************************************************************
665
// <= operator
666
//*********************************************************************
667
template
<
typename
T>
668
friend
ETL_CONSTEXPR
669
#if ETL_USING_CPP11
670
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
671
#else
672
bool
673
#endif
674
operator <=(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
675
{
676
return
lhs
.value <=
rhs
;
677
}
678
679
//*********************************************************************
680
template
<
typename
T>
681
friend
ETL_CONSTEXPR
682
#if ETL_USING_CPP11
683
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
684
#else
685
bool
686
#endif
687
operator <=(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
688
{
689
return
lhs
<=
rhs
.value;
690
}
691
692
//*********************************************************************
693
friend
ETL_CONSTEXPR
bool
operator <=(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
694
{
695
return
lhs
.value <=
rhs
.value;
696
}
697
698
//*********************************************************************
699
// > operator
700
//*********************************************************************
701
template
<
typename
T>
702
friend
ETL_CONSTEXPR
703
#if ETL_USING_CPP11
704
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
705
#else
706
bool
707
#endif
708
operator >(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
709
{
710
return
lhs
.value >
rhs
;
711
}
712
713
//*********************************************************************
714
template
<
typename
T>
715
friend
ETL_CONSTEXPR
716
#if ETL_USING_CPP11
717
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
718
#else
719
bool
720
#endif
721
operator >(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
722
{
723
return
lhs
>
rhs
.value;
724
}
725
726
//*********************************************************************
727
friend
ETL_CONSTEXPR
bool
operator >(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
728
{
729
return
lhs
.value >
rhs
.value;
730
}
731
732
//*********************************************************************
733
// >= operator
734
//*********************************************************************
735
template
<
typename
T>
736
friend
ETL_CONSTEXPR
737
#if ETL_USING_CPP11
738
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
739
#else
740
bool
741
#endif
742
operator >=(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
743
{
744
return
lhs
.value >=
rhs
;
745
}
746
747
//*********************************************************************
748
template
<
typename
T>
749
friend
ETL_CONSTEXPR
750
#if ETL_USING_CPP11
751
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
752
#else
753
bool
754
#endif
755
operator >=(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
756
{
757
return
lhs
>=
rhs
.value;
758
}
759
760
//*********************************************************************
761
friend
ETL_CONSTEXPR
bool
operator >=(
const
type_def
&
lhs
,
const
type_def
&
rhs
)
762
{
763
return
lhs
.value >=
rhs
.value;
764
}
765
766
//*********************************************************************
767
// == operator
768
//*********************************************************************
769
template
<
typename
T>
770
friend
ETL_CONSTEXPR
771
#if ETL_USING_CPP11
772
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
773
#else
774
bool
775
#endif
776
operator ==(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
777
{
778
return
lhs
.value ==
rhs
;
779
}
780
781
//*********************************************************************
782
template
<
typename
T>
783
friend
ETL_CONSTEXPR
784
#if ETL_USING_CPP11
785
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
786
#else
787
bool
788
#endif
789
operator ==(
T
lhs
,
const
type_def
&
rhs
)
790
{
791
return
lhs
==
rhs
.value;
792
}
793
794
//*********************************************************************
795
friend
ETL_CONSTEXPR
bool
operator ==(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
796
{
797
return
lhs
.value ==
rhs
.value;
798
}
799
800
//*********************************************************************
801
// != operator
802
//*********************************************************************
803
template
<
typename
T>
804
friend
ETL_CONSTEXPR
805
#if ETL_USING_CPP11
806
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
807
#else
808
bool
809
#endif
810
operator !=(
const
type_def
&
lhs
,
T
rhs
) ETL_NOEXCEPT
811
{
812
return
lhs
.value !=
rhs
;
813
}
814
815
//*********************************************************************
816
template
<
typename
T>
817
friend
ETL_CONSTEXPR
818
#if ETL_USING_CPP11
819
typename
etl::enable_if<etl::is_convertible<T, TValue>::value
,
bool
>::type
820
#else
821
bool
822
#endif
823
operator !=(
T
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
824
{
825
return
lhs
!=
rhs
.value;
826
}
827
828
//*********************************************************************
829
friend
ETL_CONSTEXPR
bool
operator !=(
const
type_def
&
lhs
,
const
type_def
&
rhs
) ETL_NOEXCEPT
830
{
831
return
lhs
.value !=
rhs
.value;
832
}
833
834
private
:
835
836
TValue
value;
837
};
838
}
839
840
#endif
etl::type_def
Definition
type_def.h:58
etl::enable_if
enable_if
Definition
type_traits_generator.h:1254
etl::is_integral
is_integral
Definition
type_traits_generator.h:1064
etl
bitset_ext
Definition
absolute.h:39
etl::round_half_even_unscaled
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition
scaled_rounding.h:315
platform.h
type_traits.h
include
etl
type_def.h
Generated on Wed May 6 2026 21:05:00 for Embedded Template Library by
1.9.8