Skip to content

Commit 1c0ccb9

Browse files
committed
Refactor Boolean<1> specialization
Signed-off-by: Alexey Bader <[email protected]>
1 parent f367478 commit 1c0ccb9

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

sycl/include/CL/sycl/detail/boolean.hpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,28 @@ template <int N> struct Boolean {
101101
};
102102

103103
template <> struct Boolean<1> {
104-
using DataType = bool;
105-
106-
Boolean() : value(false) {}
107-
108-
Boolean(const Boolean &rhs) : value(rhs.value) {}
104+
Boolean() = default;
109105

106+
// Build from a signed interger type
110107
template <typename T> Boolean(T val) : value(val) {
111108
static_assert(is_sgeninteger<T>::value, "Invalid constructor");
112109
}
113110

114-
#ifdef __SYCL_DEVICE_ONLY__
115-
using vector_t = DataType;
116-
Boolean(const vector_t rhs) : value(rhs) {}
117-
118-
operator vector_t() const { return value; }
119-
#endif
120-
111+
// Cast to a signed interger type
121112
template <typename T> operator T() const {
122113
static_assert(is_sgeninteger<T>::value, "Invalid conversion");
123114
return value;
124115
}
125116

117+
#ifdef __SYCL_DEVICE_ONLY__
118+
// Build from a boolean type
119+
Boolean(bool f) : value(f) {}
120+
// Cast to a boolean type
121+
operator bool() const { return value; }
122+
#endif
123+
126124
private:
127-
alignas(1) DataType value;
125+
alignas(1) bool value = false;
128126
};
129127

130128
} // namespace detail

0 commit comments

Comments
 (0)