ASSERT_WE_THINK trailing byte is '\0'

This commit is contained in:
Andrew Noyes 2019-04-15 09:43:26 -07:00
parent 369c1a0230
commit dced9232d0
2 changed files with 8 additions and 3 deletions

View File

@ -1218,3 +1218,8 @@ void TraceEventFields::validateFormat() const {
}
}
}
std::string traceableStringToString(const char* value, size_t S) {
ASSERT_WE_THINK(value[S - 1] == '\0');
return std::string(value, S - 1); // Exclude trailing \0 byte
}

View File

@ -262,6 +262,8 @@ struct TraceableString<const char*> {
}
};
std::string traceableStringToString(const char* value, size_t S);
template<size_t S>
struct TraceableString<char[S]> {
static const char* begin(const char* value) {
@ -272,9 +274,7 @@ struct TraceableString<char[S]> {
return iter - value == S - 1; // Exclude trailing \0 byte
}
static std::string toString(const char* value) {
return std::string(value, S - 1); // Exclude trailing \0 byte
}
static std::string toString(const char* value) { return traceableStringToString(value, S); }
};
template<>