Specialize StrLen for char/wchar_t
Compilers generally provide a much smarter strlen than ours.
This commit is contained in:
parent
f349456bc5
commit
6e2e5c7dbe
@ -16,6 +16,7 @@
|
|||||||
#define RAPIDJSON_INTERNAL_STRFUNC_H_
|
#define RAPIDJSON_INTERNAL_STRFUNC_H_
|
||||||
|
|
||||||
#include "../stream.h"
|
#include "../stream.h"
|
||||||
|
#include <cwchar>
|
||||||
|
|
||||||
RAPIDJSON_NAMESPACE_BEGIN
|
RAPIDJSON_NAMESPACE_BEGIN
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -34,6 +35,16 @@ inline SizeType StrLen(const Ch* s) {
|
|||||||
return SizeType(p - s);
|
return SizeType(p - s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline SizeType StrLen(const char* s) {
|
||||||
|
return SizeType(std::strlen(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline SizeType StrLen(const wchar_t* s) {
|
||||||
|
return SizeType(std::wcslen(s));
|
||||||
|
}
|
||||||
|
|
||||||
//! Returns number of code points in a encoded string.
|
//! Returns number of code points in a encoded string.
|
||||||
template<typename Encoding>
|
template<typename Encoding>
|
||||||
bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) {
|
bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user