Skip to content
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

wil::zwstring_view needs a formatter #513

Open
jonwis opened this issue Mar 31, 2025 · 1 comment
Open

wil::zwstring_view needs a formatter #513

jonwis opened this issue Mar 31, 2025 · 1 comment
Labels
feature-request New feature or request improvement Something that would improve the repo in some way

Comments

@jonwis
Copy link
Member

jonwis commented Mar 31, 2025

Saying this:

wil::zwstring_view v{L"foo, bar"};
auto m = std::format(L"{}", v);

Produces the usual inscrutable "you can't format that but I won't explain why" thing. Using v.c_str() works fine. Presumably that's because there's no std::formatter<wil::zwstring_view> alike, and we need to provide something like this from the STL's __msvc_formatter.hpp:

template <_Format_supported_charT _CharT, class _Traits>
struct formatter<basic_string_view<_CharT, _Traits>, _CharT>
    : _Formatter_base<basic_string_view<_CharT, _Traits>, _CharT, _Basic_format_arg_type::_String_type> {
#if _HAS_CXX23
    constexpr void set_debug_format() noexcept {
        this->_Set_debug_format();
    }
#endif // _HAS_CXX23
};
@dunhor dunhor added feature-request New feature or request improvement Something that would improve the repo in some way labels Mar 31, 2025
@dunhor
Copy link
Member

dunhor commented Mar 31, 2025

I wonder if simple inheritance would work since zstring_view derives from basic_string_view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request improvement Something that would improve the repo in some way
Projects
None yet
Development

No branches or pull requests

2 participants