cast: silence warnings when lossless casting to smaller sized enums
This commit is contained in:
parent
9eb2784d84
commit
98e9fe45c4
9
cast.hpp
9
cast.hpp
@ -116,9 +116,16 @@ namespace cruft::cast {
|
|||||||
// is lossless.
|
// is lossless.
|
||||||
CHECK_EQ (static_cast<SrcT> (dst), src);
|
CHECK_EQ (static_cast<SrcT> (dst), src);
|
||||||
return dst;
|
return dst;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
||||||
|
if constexpr (std::is_enum_v<DstT>) {
|
||||||
|
auto const val = static_cast<std::underlying_type_t<DstT>> (src);
|
||||||
|
return static_cast<DstT> (val);
|
||||||
|
} else {
|
||||||
return static_cast<DstT> (src);
|
return static_cast<DstT> (src);
|
||||||
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user