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

3654. basic_format_context::arg(size_t) should be noexcept

Section: 22.14.6.7 [format.context] Status: C++23 Submitter: Hewill Kang Opened: 2021-12-26 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [format.context].

View all issues with C++23 status.

Discussion:

basic_format_context::arg(size_t) simply returns args_.get(id) to get the elements of args_, where the type of args_ is basic_format_args<basic_format_context>. Since basic_format_args's get(size_t) is noexcept, this function can also be noexcept.

[2022-01-30; Reflector poll]

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

[2022-02-10 Approved at February 2022 virtual plenary. Status changed: Tentatively Ready → WP.]

Proposed resolution:

This wording is relative to N4901.

  1. Modify 22.14.6.7 [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
      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);
      };
    }
    

    […]

    basic_format_arg<basic_format_context> arg(size_t id) const noexcept;
    

    -5- Returns: args_.get(id).