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

Fix conversion warning in filesystem::path formatter #3806

Merged
merged 2 commits into from
Jan 13, 2024

Conversation

hmbj
Copy link
Contributor

@hmbj hmbj commented Jan 13, 2024

Use template character type to eliminate MSVC conversion warning when formatting a wide chararacter path:

fmt\std.h(140,49): warning C4244: '=': conversion from 'const Char' to 'char', possible loss of data

Use template character type to eliminate MSVC conversion warning when
formatting a wide chararacter path:

fmt\std.h(140,49): warning C4244: '=': conversion from 'const Char' to 'char', possible loss of data
@@ -120,7 +120,7 @@ template <typename Char> struct formatter<std::filesystem::path, Char> {
format_specs<Char> specs_;
detail::arg_ref<Char> width_ref_;
bool debug_ = false;
char path_type_ = 0;
Char path_type_ = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep char here and use to_ascii when assigning to it in parse.

@hmbj hmbj marked this pull request as ready for review January 13, 2024 16:01
@vitaut vitaut merged commit 7c163ac into fmtlib:master Jan 13, 2024
41 checks passed
@vitaut
Copy link
Contributor

vitaut commented Jan 13, 2024

Thank you!

@hmbj hmbj deleted the fix-filesystem-path-formatter-char-type branch January 13, 2024 16:03
happymonkey1 pushed a commit to happymonkey1/fmt that referenced this pull request Apr 7, 2024
* Fix conversion warning in filesystem::path formatter

Use template character type to eliminate MSVC conversion warning when
formatting a wide chararacter path:

fmt\std.h(140,49): warning C4244: '=': conversion from 'const Char' to 'char', possible loss of data

* Review: use to_ascii instead

---------

Co-authored-by: Hans-Martin B. Jensen <haje@eposaudio.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants