Add support for simple empty StringView.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-08-08 11:26:46 +02:00
parent 18c7c3ddcb
commit d8c3fe1436
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 10 additions and 0 deletions

View File

@ -4,4 +4,7 @@
namespace ArbUt {
std::shared_ptr<__ConstStringCharHolder> StringView::__emptyString =
std::make_shared<__ConstStringCharHolder>("", 0);
static StringView __empty;
const StringView& StringView::Empty() { return __empty; }
}

View File

@ -86,6 +86,8 @@ namespace ArbUt {
CalculateHash(const std::string_view& val) noexcept {
return Hash(val.data());
}
static const StringView& Empty();
};
}

View File

@ -76,4 +76,9 @@ TEST_CASE("Out of scope char* doesn't lose reference", "[Utilities]") {
REQUIRE(strcmp(val.c_str(), "foobar") == 0);
}
TEST_CASE("Get Empty String", "[Utilities]") {
REQUIRE(ArbUt::StringView::Empty() == ""_cnc);
}
#endif