Explaining decision.

This commit is contained in:
Daniel Lemire 2020-06-21 18:02:34 -04:00
parent 38bb08778a
commit 066269153e
1 changed files with 8 additions and 1 deletions

View File

@ -89,7 +89,14 @@ public:
return UNSUPPORTED_ARCHITECTURE;
}
WARN_UNUSED bool validate_utf8(const char *, size_t) const noexcept final override {
return false; // just refuse the validate
return false; // Just refuse to validate. Given that we have a fallback implementation
// it seems unlikely that unsupported_implementation will ever be used. If it is used,
// then it will flag all strings as invalid. The alternative is to return an error_code
// from which the user has to figure out whether the string is valid UTF-8... which seems
// like a lot of work just to handle the very unlikely case that we have an unsupported
// implementation. And, when it does happen (that we have an unsupported implementation),
// what are the chances that the programmer has a fallback? Given that *we* provide the
// fallback, it implies that the programmer would need a fallback for our fallback.
}
unsupported_implementation() : implementation("unsupported", "Unsupported CPU (no detected SIMD instructions)", 0) {}
};