From 6365f36c75cb6c96792a3a15099b62b20cc5baff Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 1 Jun 2013 23:55:52 +0900 Subject: [PATCH] Fixed compilation error with GCC4.2 --- taglib/toolkit/tbytevector.cpp | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 11cc67d5..ce47fbb8 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -296,6 +296,25 @@ ulonglong byteSwap(ulonglong x) #endif } +template +T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignificantByteFirst) +{ + if(offset >= v.size()) { + debug("toNumber() -- No data to convert. Returning 0."); + return 0; + } + + length = std::min(length, v.size() - offset); + + T sum = 0; + for(size_t i = 0; i < length; i++) { + const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8; + sum |= static_cast(static_cast(v[offset + i])) << shift; + } + + return sum; +} + template T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst) { @@ -317,25 +336,6 @@ T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst) return tmp; } -template -T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignificantByteFirst) -{ - if(offset >= v.size()) { - debug("toNumber() -- No data to convert. Returning 0."); - return 0; - } - - length = std::min(length, v.size() - offset); - - T sum = 0; - for(size_t i = 0; i < length; i++) { - const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8; - sum |= static_cast(static_cast(v[offset + i])) << shift; - } - - return sum; -} - template ByteVector fromNumber(T value, bool mostSignificantByteFirst) {