Title
Should std::basic_format_context be default-constructible/copyable/movable?
Status
wp
Section
[format.context]
Submitter
Jiang An

Created on 2024-03-24.00:00:00 last changed 5 months ago

Messages

Date: 2024-07-08.09:00:03

Proposed resolution:

This wording is relative to N4971.

  1. Modify [format.context] as indicated:

    namespace std {
      template<class Out, class charT>
      class basic_format_context {
        basic_format_args<basic_format_context> args_; // exposition only
        Out out_;                                      // exposition only
    
        basic_format_context(const basic_format_context&) = delete;
        basic_format_context& operator=(const basic_format_context&) = delete;
      public:
        using iterator = Out;
        using char_type = charT;
        template<class T> using formatter_type = formatter<T, charT>;
        
        basic_format_arg<basic_format_context> arg(size_t id) const noexcept;
        std::locale locale();
        
        iterator out();
        void advance_to(iterator it);
      };
    }
    
Date: 2024-07-08.09:00:03

[ St. Louis 2024-06-29; Status changed: Voting → WP. ]

Date: 2024-05-15.00:00:00

[ 2024-05-08; Reflector poll ]

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

Date: 2024-03-24.00:00:00

Per [format.context], it seems that std::basic_format_context has a default constructor that is effectively defaulted, which means that it is default constructible if and only if OutIt is default constructible. Currently only libstdc++ makes it conditionally default constructible, while libc++ and MSVC STL (together with fmtlib) make it never default constructible.

It seems that basic_format_context objects are supposed to be created by the implementation in some internal way, and user codes are only supposed to modify existing basic_format_context objects during formatting.

History
Date User Action Args
2024-07-08 09:00:03adminsetmessages: + msg14238
2024-07-08 09:00:03adminsetstatus: voting -> wp
2024-06-24 13:01:55adminsetstatus: ready -> voting
2024-05-08 10:36:29adminsetmessages: + msg14120
2024-05-08 10:36:29adminsetstatus: new -> ready
2024-03-26 15:08:20adminsetmessages: + msg14028
2024-03-24 00:00:00admincreate