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
35 ByteBool& operator=(bool b)
36 {
37 m_val = b;
38 return *this;
39 }
40
43 operator bool() const
44 {
45 return !!m_val;
46 }
47
51 bool operator==(ByteBool rhs) const { return !!m_val == !!rhs.m_val; }
52
56 bool operator==(bool rhs) const { return !!m_val == rhs; }
57
61 bool operator<(ByteBool rhs) const { return !!m_val < !!rhs.m_val; }
62
66 bool operator<(bool rhs) const { return !!m_val < rhs; }
67};
68
73inline bool operator==(bool lhs, ByteBool rhs) { return rhs.operator==(lhs); }
74
79inline bool operator!=(ByteBool lhs, ByteBool rhs) { return !lhs.operator==(rhs); }
80
85inline bool operator!=(ByteBool lhs, bool rhs) { return !lhs.operator==(rhs); }
86
91inline bool operator!=(bool lhs, ByteBool rhs) { return !operator==(lhs, rhs); }
92
97inline bool operator<(bool lhs, ByteBool rhs) { return (lhs != rhs) && !(rhs < lhs); }
98//TODO >, <=, >= operators
99
100static_assert(sizeof(ByteBool) == 1, "Size of ByteBool must be 1");
101static_assert(sizeof(ByteBool[17]) == 17, "Alignment of ByteBool must be 1");
102static_assert(std::is_standard_layout<ByteBool>::value, "ByteBool must have Standard Layout");
103
105template<typename T>
106struct SelectType
107{
109 using type = T;
110};
111
113template<>
114struct SelectType<bool>
115{
117 using type = Details::ByteBool;
118};
119
120} // namespace Details
121} // namespace System
Definition: db_command.h:9
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:157
constexpr bool operator<(std::nullptr_t, DateTime)
Definition: date_time.h:712
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:151