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

Remove double forward #1387

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

sylveon
Copy link
Contributor

@sylveon sylveon commented Jan 17, 2024

This fixes the code analysis warnings pointed out by @dmachaj. We can't just really switch to using Args const&... because some types cannot be formatted as const lvalues - most notably ranges::filter_view. So instead, we take a forwarding reference, but don't actually call std::forward, resulting in all the arguments being passed to std::format as lvalue references.

Formatters that care about the exact value category should feel bad.

WINRT_ASSERT(size < UINT_MAX);
auto const size32 = static_cast<uint32_t>(size);

hstring_builder builder(size32);
WINRT_VERIFY_(size32, std::format_to_n(builder.data(), size32, std::forward<Args>(args)...).size);
WINRT_VERIFY_(size32, std::format_to_n(builder.data(), size32, args...).size);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like you could still forward here. Although I guess without the first forward there's not much point anymore...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While formatters don't care about value category, apparently std::format_string does. So forwarding in one place but not the other would break it (like it currently is).

@dmachaj
Copy link
Contributor

dmachaj commented Jan 17, 2024

Looks like this change introduced some build breaks in the cpp20 test code :(

@sylveon
Copy link
Contributor Author

sylveon commented Jan 17, 2024

Yeah, should've actually tested it haha. Lemme fix that.

@sylveon
Copy link
Contributor Author

sylveon commented Jan 17, 2024

Should work now :)

@dmachaj dmachaj merged commit 91f485f into microsoft:master Jan 22, 2024
75 checks passed
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.

None yet

2 participants