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

Fixes misapplied resolution of LWG3539 #5069

Merged

Conversation

mordante
Copy link
Contributor

@mordante mordante commented Oct 24, 2021

LWG3539 has the following resolution

template<class Out, class... Args>
Out format_to(Out out, string_view fmt, const Args&... args);
template<class Out, class... Args>
Out format_to(Out out, wstring_view fmt, const Args&... args);

-8- Effects: Equivalent to:

    using context = basic_format_context<Out, decltype(fmt)::value_type>;
    return vformat_to(<add>std::move(</add>out<add>)</add>, fmt, make_format_args<context>(args...));

template<class Out, class... Args>
Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);
template<class Out, class... Args>
Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);

-9- Effects: Equivalent to:

    using context = basic_format_context<Out, decltype(fmt)::value_type>;
    return vformat_to(<add>std::move(</add>out<add>)</add>, loc, fmt, make_format_args<context>(args...));

In the current Standard every overload has its own Effects paragraph.
The proposed resolution is only applied to the wstring_view overloads.

This seems to a be mistake. This patch applies the resolution to the
string_view overloads; currently named format-string.

LWG 3539 has the following resolution

template<class Out, class... Args>
  Out format_to(Out out, string_view fmt, const Args&... args);
template<class Out, class... Args>
  Out format_to(Out out, wstring_view fmt, const Args&... args);

    -8- Effects: Equivalent to:

        using context = basic_format_context<Out, decltype(fmt)::value_type>;
        return vformat_to(<add>std::move(</add>out<add>)</add>, fmt, make_format_args<context>(args...));

template<class Out, class... Args>
  Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);
template<class Out, class... Args>
  Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);

    -9- Effects: Equivalent to:

        using context = basic_format_context<Out, decltype(fmt)::value_type>;
        return vformat_to(<add>std::move(</add>out<add>)</add>, loc, fmt, make_format_args<context>(args...));

In the current Standard every overload has its own Effects paragraph.
The proposed resolution is only applied to the wstring_view overloads.

This seems to a be mistake. This patch applies the resolution to the
string_view overloads; currently named format-string.
@tkoeppe
Copy link
Contributor

tkoeppe commented Oct 24, 2021

LWG3539 was applied by cf4caae.

But it seems to have since been modified by 4126c12 (P2216R3 std::format improvements).

Copy link
Contributor

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

This correctly restores the intent of LWG-3539, which is that format overloads pass their out parameter to vformat_to as an xvalue to support move-only single-pass iterators.

@jensmaurer jensmaurer changed the title Fixes misapplied resolution of LWG 3539. Fixes misapplied resolution of LWG3539 Oct 24, 2021
@jensmaurer jensmaurer added this to the C++23 milestone Oct 26, 2021
@tkoeppe tkoeppe merged commit ba4bb3e into cplusplus:main Nov 23, 2021
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

4 participants