-
Notifications
You must be signed in to change notification settings - Fork 289
Enable using string views with wil::str_concat #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
c0670e8
85a381a
75727f9
704ffe4
a8c87de
ec3c068
5dc5e5f
18ec4f9
a80eb35
2748fe4
45fb091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,21 @@ | |
| // TODO: str_raw_ptr is not two-phase name lookup clean (https://github.com/Microsoft/wil/issues/8) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's been too long since I've last thought about this issue, but I wonder - if we're introducing a new function, is there's something we can do to fix this for [1] Function templates don't allow partial specialization and are therefore not suitable here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note: we can also maybe provide a specialization for Another possibility is to have detection logic in the base class template for something that is "string view like." E.g. something that has
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although it seems my memory is wrong... |
||
| namespace wil | ||
| { | ||
| struct string_view_t; | ||
|
|
||
| PCWSTR str_raw_ptr(HSTRING); | ||
| string_view_t view_from_string(HSTRING); | ||
| #ifdef WIL_ENABLE_EXCEPTIONS | ||
| PCWSTR str_raw_ptr(const std::wstring&); | ||
| string_view_t view_from_string(std::wstring const&); | ||
| string_view_t view_from_string(std::wstring_view const&); | ||
| #endif | ||
| } // namespace wil | ||
|
|
||
| #ifdef WIL_ENABLE_EXCEPTIONS | ||
| #include <wil/stl.h> | ||
| #endif | ||
|
|
||
| #include <wil/resource.h> | ||
| #include <wil/filesystem.h> | ||
|
|
||
|
|
@@ -528,6 +537,20 @@ TEST_CASE("FileSystemTests::VerifyStrConcat", "[filesystem]") | |
| REQUIRE_SUCCEEDED(wil::str_concat_nothrow(combinedStringNT, test2.c_str(), test3)); | ||
| REQUIRE(CompareStringOrdinal(combinedStringNT.get(), -1, expectedStr, -1, TRUE) == CSTR_EQUAL); | ||
| } | ||
|
|
||
| #ifdef WIL_ENABLE_EXCEPTIONS | ||
| SECTION("Concat with views of things") | ||
| { | ||
| auto part1 = std::wstring_view(L"Test2"); | ||
| auto part2 = std::wstring(L"Test3"); | ||
| auto part3 = wil::zwstring_view(L"Test4"); | ||
| auto part4 = wil::make_unique_string_nothrow<wil::unique_cotaskmem_string>(L"Test5"); | ||
| auto part5 = wil::make_unique_string_nothrow<wil::unique_hstring>(L"Test6"); | ||
| wil::unique_cotaskmem_string combinedStringNT = wil::make_unique_string_nothrow<wil::unique_cotaskmem_string>(L"Test1"); | ||
| REQUIRE_SUCCEEDED(wil::str_concat_nothrow(combinedStringNT, part1, part2, part3, part4, part5)); | ||
| REQUIRE(CompareStringOrdinal(combinedStringNT.get(), -1, L"Test1Test2Test3Test4Test5Test6", -1, TRUE) == CSTR_EQUAL); | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| TEST_CASE("FileSystemTests::VerifyStrPrintf", "[filesystem]") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.