diff options
author | Jacques Lucke <jacques@blender.org> | 2020-08-10 19:13:28 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-08-10 19:17:07 +0300 |
commit | c521b69ffb68df17d6b8e1c71d23924a8b9b9cf3 (patch) | |
tree | 69f9505c110e7f1ce7769e0036f51eb439f20635 /source/blender/blenlib/tests/BLI_set_test.cc | |
parent | 53d203dea8230da4e80f3cc61468a4e24ff6759c (diff) |
BLI: improve StringRef for C++17
Since C++17 there is also std::string_view, which is similar to StringRef.
This commit does a couple of things:
* New implicit conversions between StringRef and std::string_view.
* Support std::string_view in blender::DefaultHash.
* Support most of the methods that std::string_view has.
* Add StringRef::not_found which can be used instead of -1 in some places.
* Improve/fix the description at the top of BLI_string_ref.hh.
Diffstat (limited to 'source/blender/blenlib/tests/BLI_set_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_set_test.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc index 7bd0b258df8..df3f7ab544c 100644 --- a/source/blender/blenlib/tests/BLI_set_test.cc +++ b/source/blender/blenlib/tests/BLI_set_test.cc @@ -452,6 +452,16 @@ TEST(set, LookupKeyPtr) EXPECT_EQ(set.lookup_key_ptr({3, 50}), nullptr); } +TEST(set, StringViewKeys) +{ + Set<std::string_view> set; + set.add("hello"); + set.add("world"); + EXPECT_FALSE(set.contains("worlds")); + EXPECT_TRUE(set.contains("world")); + EXPECT_TRUE(set.contains("hello")); +} + /** * Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot. */ |