From d174f3f15767ee828854fb8eb81a988282168532 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 31 May 2018 22:43:35 +0200 Subject: [PATCH] Make toInt() functions constexpr --- conversion/binaryconversionprivate.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conversion/binaryconversionprivate.h b/conversion/binaryconversionprivate.h index f2816ae..339ede6 100644 --- a/conversion/binaryconversionprivate.h +++ b/conversion/binaryconversionprivate.h @@ -9,7 +9,7 @@ /*! * \brief Returns a 16-bit signed integer converted from two bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline int16 toInt16(const char *value) +CPP_UTILITIES_EXPORT constexpr int16 toInt16(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 8 & 0xFF00) | (static_cast(value[1]) & 0x00FF); @@ -21,7 +21,7 @@ CPP_UTILITIES_EXPORT inline int16 toInt16(const char *value) /*! * \brief Returns a 16-bit unsigned integer converted from two bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline uint16 toUInt16(const char *value) +CPP_UTILITIES_EXPORT constexpr uint16 toUInt16(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 8 & 0xFF00) | (static_cast(value[1]) & 0x00FF); @@ -33,7 +33,7 @@ CPP_UTILITIES_EXPORT inline uint16 toUInt16(const char *value) /*! * \brief Returns a 32-bit signed integer converted from four bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline int32 toInt32(const char *value) +CPP_UTILITIES_EXPORT constexpr int32 toInt32(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 24 & 0xFF000000) | (static_cast(value[1]) << 16 & 0x00FF0000) @@ -47,7 +47,7 @@ CPP_UTILITIES_EXPORT inline int32 toInt32(const char *value) /*! * \brief Returns a 32-bit unsigned integer converted from three bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline uint32 toUInt24(const char *value) +CPP_UTILITIES_EXPORT constexpr uint32 toUInt24(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 16 & 0x00FF0000) | (static_cast(value[1]) << 8 & 0x0000FF00) @@ -61,7 +61,7 @@ CPP_UTILITIES_EXPORT inline uint32 toUInt24(const char *value) /*! * \brief Returns a 32-bit unsigned integer converted from four bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline uint32 toUInt32(const char *value) +CPP_UTILITIES_EXPORT constexpr uint32 toUInt32(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 24 & 0xFF000000) | (static_cast(value[1]) << 16 & 0x00FF0000) @@ -75,7 +75,7 @@ CPP_UTILITIES_EXPORT inline uint32 toUInt32(const char *value) /*! * \brief Returns a 64-bit signed integer converted from eight bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline int64 toInt64(const char *value) +CPP_UTILITIES_EXPORT constexpr int64 toInt64(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 56 & 0xFF00000000000000) | (static_cast(value[1]) << 48 & 0x00FF000000000000) @@ -93,7 +93,7 @@ CPP_UTILITIES_EXPORT inline int64 toInt64(const char *value) /*! * \brief Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a char array. */ -CPP_UTILITIES_EXPORT inline uint64 toUInt64(const char *value) +CPP_UTILITIES_EXPORT constexpr uint64 toUInt64(const char *value) { #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 return (static_cast(value[0]) << 56 & 0xFF00000000000000) | (static_cast(value[1]) << 48 & 0x00FF000000000000)