Title
vformat_to should not try to deduce Out twice
Status
c++20
Section
[format.functions]
Submitter
Tim Song

Created on 2020-01-16.00:00:00 last changed 46 months ago

Messages

Date: 2020-02-01.13:12:42

Proposed resolution:

This wording is relative to N4842.

  1. Edit [format.syn], header <format> synopsis, as indicated:

    namespace std {
    
      […]
    
      template<class Out>
        Out vformat_to(Out out, string_view fmt, format_args_t<type_identity_t<Out>, char> args);
      template<class Out>
        Out vformat_to(Out out, wstring_view fmt, format_args_t<type_identity_t<Out>, wchar_t> args);
      template<class Out>
        Out vformat_to(Out out, const locale& loc, string_view fmt,
                       format_args_t<type_identity_t<Out>, char> args);
      template<class Out>
        Out vformat_to(Out out, const locale& loc, wstring_view fmt,
                       format_args_t<type_identity_t<Out>, wchar_t> args);
    
      […]
    }
    
  2. Edit [format.functions] p8 through p10 as indicated:

    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(out, 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(out, loc, fmt, {make_format_args<context>(args...)});
    
      template<class Out>
        Out vformat_to(Out out, string_view fmt, format_args_t<type_identity_t<Out>, char> args);
      template<class Out>
        Out vformat_to(Out out, wstring_view fmt, format_args_t<type_identity_t<Out>, wchar_t> args);
      template<class Out>
        Out vformat_to(Out out, const locale& loc, string_view fmt,
                       format_args_t<type_identity_t<Out>, char> args);
      template<class Out>
        Out vformat_to(Out out, const locale& loc, wstring_view fmt,
                       format_args_t<type_identity_t<Out>, wchar_t> args);
    

    -10- Let charT be decltype(fmt)::value_type.

    […]

Date: 2020-02-01.00:00:00

[ 2020-02-01 Status set to Tentatively Ready after six positive votes on the reflector. ]

Date: 2020-01-16.00:00:00

vformat_to currently deduces Out from its first and last arguments. This requires its last argument's type to be a specialization of basic_format_args, which notably prevents the use of format-arg-store arguments directly. This is unnecessary: we should only deduce from the first argument.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-14 06:37:09adminsetstatus: ready -> immediate
2020-02-01 13:12:42adminsetmessages: + msg10972
2020-02-01 13:12:42adminsetstatus: new -> ready
2020-01-17 03:58:59adminsetmessages: + msg10944
2020-01-16 00:00:00admincreate