CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
select_type.h
1
3#pragma once
4
5#include <type_traits>
6#include <fwd.h>
7
8namespace System
9{
10
11namespace Details
12{
13
15struct ByteBool
16{
18 typedef uint8_t InternalType;
19
21 InternalType m_val;
22
24 ByteBool()
25 : m_val(false) {}
26
29 explicit ByteBool(bool b)
30 : m_val(b) {}
31
34 bool Equals(const ByteBool& other)
35 {
36 return *this == other;
37 }
38
41 bool Equals(bool other)
42 {
43 return !!m_val == other;
44 }
45
49 ByteBool& operator=(bool b)
50 {
51 m_val = b;
52 return *this;
53 }
54
57 operator bool() const
58 {
59 return !!m_val;
60 }
61
65 bool operator==(ByteBool rhs) const { return !!m_val == !!rhs.m_val; }
66
70 bool operator==(bool rhs) const { return !!m_val == rhs; }
71
75 bool operator<(ByteBool rhs) const { return !!m_val < !!rhs.m_val; }
76
80 bool operator<(bool rhs) const { return !!m_val < rhs; }
81};
82
87inline bool operator==(bool lhs, ByteBool rhs) { return rhs.operator==(lhs); }
88
93inline bool operator!=(ByteBool lhs, ByteBool rhs) { return !lhs.operator==(rhs); }
94
99inline bool operator!=(ByteBool lhs, bool rhs) { return !lhs.operator==(rhs); }
100
105inline bool operator!=(bool lhs, ByteBool rhs) { return !operator==(lhs, rhs); }
106
111inline bool operator<(bool lhs, ByteBool rhs) { return (lhs != rhs) && !(rhs < lhs); }
112//TODO >, <=, >= operators
113
114static_assert(sizeof(ByteBool) == 1, "Size of ByteBool must be 1");
115static_assert(sizeof(ByteBool[17]) == 17, "Alignment of ByteBool must be 1");
116static_assert(std::is_standard_layout<ByteBool>::value, "ByteBool must have Standard Layout");
117
119template<typename T>
120struct SelectType
121{
123 using type = T;
124};
125
127template<>
128struct SelectType<bool>
129{
131 using type = Details::ByteBool;
132};
133
134} // namespace Details
135} // namespace System
Definition: db_command.h:9
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:156
bool Equals(const TA &a, const TB &b)
Determines the equality of two values applying operator==() to them.
Definition: primitive_types.h:77
constexpr bool operator<(std::nullptr_t, DateTime)
Definition: date_time.h:712
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:150