StrLen: align implementations

There are two copies of `StrLen` in the RapidJSON code base
 * strfunc.h: rapidjson::internal::StrLen<Ch>
 * unittest.h: Strlen<Ch>

To hide a warning on MSVC, align both implementations to use
'unsigned/SizeType' as return type and add an explicit cast.
This commit is contained in:
Philipp A. Hartmann 2014-07-10 16:46:42 +02:00 committed by Philipp A. Hartmann
parent 4f40ed64b6
commit 7a2e6e79c6
2 changed files with 3 additions and 4 deletions

View File

@ -13,8 +13,7 @@ namespace internal {
template <typename Ch> template <typename Ch>
inline SizeType StrLen(const Ch* s) { inline SizeType StrLen(const Ch* s) {
const Ch* p = s; const Ch* p = s;
while (*p != '\0') while (*p) ++p;
++p;
return SizeType(p - s); return SizeType(p - s);
} }

View File

@ -27,10 +27,10 @@
#endif #endif
template <typename Ch> template <typename Ch>
inline size_t StrLen(const Ch* s) { inline unsigned StrLen(const Ch* s) {
const Ch* p = s; const Ch* p = s;
while (*p) p++; while (*p) p++;
return p - s; return unsigned(p - s);
} }
template<typename Ch> template<typename Ch>