summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-02-01 20:44:18 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 19:39:26 +0000
commit2cb7f28ec9351af4440d9597eb3d053809141541 (patch)
treef823361fa635eb0fad18a84b2d8d28305259e112 /src/corelib
parent44ab48db21efcfe74d3c8c6dc32562f95ed6e354 (diff)
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qtools_p.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 9efd964205..b48ed94236 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -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