fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.83k stars 2.42k forks source link

question about missing basic_format_args constructor in v11 #4045

Closed odygrd closed 3 days ago

odygrd commented 3 days ago

Hello, I used to have some code like the following in v10 :

    unsigned long long get_arg_types() const
    {
      return fmt::detail::is_unpacked_bit | _data.size();
    }

    fmt::basic_format_arg<fmt::format_context> const* get_arg_data() const
    {
      return _data.data();
    }

    std::string formatted_values_str;
    std::string format_string;

    fmt::vformat_to(std::back_inserter(formatted_values_str), format_string,
                         fmt::basic_format_args<fmt::format_context>{
                           get_arg_types(), get_arg_data()});

It seems that in v11 this basic_format_args constructor has been removed

 constexpr basic_format_args(unsigned long long desc, const format_arg* args)
    : desc_(desc), args_(args) {}

Is there any alternative I can use in v11 to achieve similar result ?

odygrd commented 3 days ago

I have switched to using the below ctor and it seems good, thank you for your work !

  constexpr basic_format_args(const format_arg* args, int count)
      : desc_(detail::is_unpacked_bit | detail::to_unsigned(count)),
        args_(args) {}