QtMiscUtils: make toHex*() constexpr
Bring them into a constexpr'able form, by indexing into the string literal directly instead of into a static const char[], which is a declaration not allowed in a C++11 constexpr function, then mark the functions constexpr. Change-Id: I6b32a55bf24f85caeb980c0c855b8db0952f914c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
44ab48db21
commit
2cb7f28ec9
|
|
@ -51,16 +51,14 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtMiscUtils {
|
||||
inline char toHexUpper(uint value) Q_DECL_NOTHROW
|
||||
Q_DECL_CONSTEXPR inline char toHexUpper(uint value) Q_DECL_NOTHROW
|
||||
{
|
||||
static const char hexdigits[] = "0123456789ABCDEF";
|
||||
return hexdigits[value & 0xF];
|
||||
return "0123456789ABCDEF"[value & 0xF];
|
||||
}
|
||||
|
||||
inline char toHexLower(uint value) Q_DECL_NOTHROW
|
||||
Q_DECL_CONSTEXPR inline char toHexLower(uint value) Q_DECL_NOTHROW
|
||||
{
|
||||
static const char hexdigits[] = "0123456789abcdef";
|
||||
return hexdigits[value & 0xF];
|
||||
return "0123456789abcdef"[value & 0xF];
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW
|
||||
|
|
|
|||
Loading…
Reference in New Issue