Skip to content

Commit

Permalink
Merge pull request #1013 from pah/fixes/1010-assert-stringref
Browse files Browse the repository at this point in the history
GenericStringRef: move assert out of expression
  • Loading branch information
miloyip committed Jul 11, 2017
2 parents 2d27ce4 + 70171f9 commit 1a77513
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/rapidjson/document.h
Expand Up @@ -308,7 +308,7 @@ struct GenericStringRef {
*/
#endif
explicit GenericStringRef(const CharType* str)
: s(str), length(((RAPIDJSON_ASSERT(str != 0)), internal::StrLen(str))) {}
: s(str), length(NotNullStrLen(str)) {}

//! Create constant string reference from pointer and length
#ifndef __clang__ // -Wdocumentation
Expand All @@ -331,6 +331,11 @@ struct GenericStringRef {
const SizeType length; //!< length of the string (excluding the trailing NULL terminator)

private:
SizeType NotNullStrLen(const CharType* str) {
RAPIDJSON_ASSERT(str != 0);
return internal::StrLen(str);
}

/// Empty string - used when passing in a NULL pointer
static const Ch emptyString[];

Expand Down

0 comments on commit 1a77513

Please sign in to comment.