Skip to content

Commit c3ba729

Browse files
committed
Prevent implicit cast for non-int underlying type
1 parent 1110cc4 commit c3ba729

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/flags/flags.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ template <class E> struct flags {
140140
}
141141

142142
friend constexpr flags operator|(flags f1, flags f2) noexcept {
143-
return flags{f1.val_ | f2.val_};
143+
return flags{static_cast<impl_type>(f1.val_ | f2.val_)};
144144
}
145145

146146
friend constexpr flags operator&(flags f1, flags f2) noexcept {
147-
return flags{f1.val_ & f2.val_};
147+
return flags{static_cast<impl_type>(f1.val_ & f2.val_)};
148148
}
149149

150150
friend constexpr flags operator^(flags f1, flags f2) noexcept {
151-
return flags{f1.val_ ^ f2.val_};
151+
return flags{static_cast<impl_type>(f1.val_ ^ f2.val_)};
152152
}
153153

154154

0 commit comments

Comments
 (0)