Improve casting
Make a handful of narrowing casts explicit Change-Id: I318e9778840f2437963377b6b97f269d569909dc Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
parent
e721ec269e
commit
a418fd5cbb
@ -72,7 +72,7 @@ class qfloat16
|
||||
// To let our private constructor work, without other code seeing
|
||||
// ambiguity when constructing from int, double &c.
|
||||
quint16 b16;
|
||||
constexpr inline explicit Wrap(int value) : b16(value) {}
|
||||
constexpr inline explicit Wrap(int value) : b16(quint16(value)) {}
|
||||
};
|
||||
public:
|
||||
constexpr inline qfloat16() noexcept : b16(0) {}
|
||||
@ -172,8 +172,8 @@ inline qfloat16::qfloat16(float f) noexcept
|
||||
#else
|
||||
quint32 u;
|
||||
memcpy(&u, &f, sizeof(quint32));
|
||||
b16 = basetable[(u >> 23) & 0x1ff]
|
||||
+ ((u & 0x007fffff) >> shifttable[(u >> 23) & 0x1ff]);
|
||||
b16 = quint16(basetable[(u >> 23) & 0x1ff]
|
||||
+ ((u & 0x007fffff) >> shifttable[(u >> 23) & 0x1ff]));
|
||||
#endif
|
||||
}
|
||||
QT_WARNING_POP
|
||||
@ -268,8 +268,8 @@ QF16_MAKE_BOOL_OP(float)
|
||||
#undef QF16_MAKE_BOOL_OP_FP
|
||||
|
||||
#define QF16_MAKE_BOOL_OP_INT(OP) \
|
||||
inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP b; } \
|
||||
inline bool operator OP(int a, qfloat16 b) noexcept { return a OP static_cast<float>(b); }
|
||||
inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } \
|
||||
inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); }
|
||||
QF16_MAKE_BOOL_OP_INT(>)
|
||||
QF16_MAKE_BOOL_OP_INT(<)
|
||||
QF16_MAKE_BOOL_OP_INT(>=)
|
||||
|
@ -101,7 +101,7 @@ private:
|
||||
static Q_DECL_RELAXED_CONSTEXPR Skiptable generate(const char *pattern, uint n) noexcept
|
||||
{
|
||||
const auto uchar_max = (std::numeric_limits<uchar>::max)();
|
||||
uchar max = n > uchar_max ? uchar_max : n;
|
||||
uchar max = n > uchar_max ? uchar_max : uchar(n);
|
||||
Skiptable table = {
|
||||
// this verbose initialization code aims to avoid some opaque error messages
|
||||
// even on powerful compilers such as GCC 5.3. Even though for GCC a loop
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
|
||||
inline int index() const
|
||||
{
|
||||
return pos - i;
|
||||
return int(pos - i);
|
||||
}
|
||||
|
||||
inline void setPosition(QString::const_iterator position)
|
||||
|
@ -77,7 +77,7 @@ Q_DECL_CONSTEXPR inline int fromHex(uint c) noexcept
|
||||
|
||||
Q_DECL_CONSTEXPR inline char toOct(uint value) noexcept
|
||||
{
|
||||
return '0' + char(value & 0x7);
|
||||
return char('0' + (value & 0x7));
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline int fromOct(uint c) noexcept
|
||||
|
@ -157,7 +157,7 @@ class QVersionNumber
|
||||
{ return isUsingPointer() ? pointer_segments->size() : (inline_segments[InlineSegmentMarker] >> 1); }
|
||||
|
||||
void setInlineSize(int len)
|
||||
{ inline_segments[InlineSegmentMarker] = 1 + 2 * len; }
|
||||
{ inline_segments[InlineSegmentMarker] = qint8(1 + 2 * len); }
|
||||
|
||||
void resize(int len)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user