This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.

4088. println ignores the locale imbued in std::ostream

Section: 31.7.6.3.5 [ostream.formatted.print] Status: WP Submitter: Jens Maurer Opened: 2024-04-30 Last modified: 2024-11-28

Priority: Not Prioritized

View all other issues in [ostream.formatted.print].

View all issues with WP status.

Discussion:

31.7.6.3.5 [ostream.formatted.print] specifies that std::print uses the locale imbued in the std::ostream& argument for formatting, by using this equivalence:

vformat(os.getloc(), fmt, args);

(in the vformat_(non)unicode delegation).

However, std::println ignores the std::ostream's locale for its locale-dependent formatting:

print(os, "{}\n", format(fmt, std::forward<Args>(args)...));

This is inconsistent.

[2024-10-03; Reflector poll]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

[Wrocław 2024-11-23; Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4981.

  1. Modify 31.7.6.3.5 [ostream.formatted.print] as indicated:

    template<class... Args>
      void println(ostream& os, format_string<Args...> fmt, Args&&... args);
    

    -2- Effects: Equivalent to:

    print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));