Skip to content

Code sample from the docs generates deprecated warning #1101

Closed
@alighazi

Description

I copy pasted the code sample from: Formatting user-defined types¶ and customized it for my own type. but it seems like ctx.begin() is marked as deprecated, what should be used instead?

this is my code

namespace fmt{
template <>
struct formatter<glm::ivec2> {
  template <typename ParseContext>
  constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }

  template <typename FormatContext>
  auto format(const glm::ivec2 &r, FormatContext &ctx) {
    return format_to(ctx.begin(), "x: {}, y: {}", r.x, r.y);
  }
};

}

and this is the generated warning:

[build] /home/jizz/code/gl/chetris/include/core/util/to_string.hpp: In instantiation of ‘auto fmt::v5::formatter<glm::vec<2, int, (glm::qualifier)0> >::format(const ivec2&, FormatContext&) [with FormatContext = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; glm::ivec2 = glm::vec<2, int, (glm::qualifier)0>]’:
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:751:5:   required from ‘static void fmt::v5::internal::value<Context>::format_custom_arg(const void*, fmt::v5::basic_parse_context<typename Context::char_type>&, Context&) [with T = glm::vec<2, int, (glm::qualifier)0>; Formatter = fmt::v5::formatter<glm::vec<2, int, (glm::qualifier)0> >; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; typename Context::char_type = char]’
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:732:19:   required from ‘fmt::v5::internal::value<Context>::value(const T&) [with T = glm::vec<2, int, (glm::qualifier)0>; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:761:58:   required from ‘constexpr fmt::v5::internal::init<Context, T, TYPE>::operator fmt::v5::internal::value<Context>() const [with Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = const glm::vec<2, int, (glm::qualifier)0>&; fmt::v5::internal::type TYPE = (fmt::v5::internal::type)13]’
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:1080:35:   required from ‘fmt::v5::internal::value<Context> fmt::v5::internal::make_arg(const T&) [with bool IS_PACKED = true; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = glm::vec<2, int, (glm::qualifier)0>; typename std::enable_if<IS_PACKED, int>::type <anonymous> = 0]’
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:1196:53:   required from ‘fmt::v5::format_arg_store<Context, Args>::format_arg_store(const Args& ...) [with Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; Args = {glm::vec<2, int, (glm::qualifier)0>}]’
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:1374:18:   required from ‘fmt::v5::format_arg_store<typename fmt::v5::buffer_context<typename fmt::v5::internal::char_t<S>::type>::type, Args ...> fmt::v5::internal::make_args_checked(const S&, const Args& ...) [with S = char [15]; Args = {glm::vec<2, int, (glm::qualifier)0>}; typename std::enable_if<fmt::v5::internal::is_string<S>::value, int>::type <anonymous> = 0; typename fmt::v5::buffer_context<typename fmt::v5::internal::char_t<S>::type>::type = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:1504:37:   required from ‘void fmt::v5::print(const S&, const Args& ...) [with S = char [15]; Args = {glm::vec<2, int, (glm::qualifier)0>}; typename std::enable_if<fmt::v5::internal::is_string<S>::value, int>::type <anonymous> = 0]’
[build] /home/jizz/code/gl/chetris/src/core/c_block.cpp:15:43:   required from here
[build] /home/jizz/code/gl/chetris/include/core/util/to_string.hpp:77:21: warning: ‘fmt::v5::basic_format_context<OutputIt, Char>::iterator fmt::v5::basic_format_context<OutputIt, Char>::begin() [with OutputIt = std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >; Char = char; fmt::v5::basic_format_context<OutputIt, Char>::iterator = std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >]’ is deprecated [-Wdeprecated-declarations]
[build]      return format_to(ctx.begin(), "x: {}, y: {}", r.x, r.y);
[build]             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from /home/jizz/code/gl/chetris/include/core/common.hpp:12:0,
[build]                  from /home/jizz/code/gl/chetris/include/core/ecs/c_block.hpp:2,
[build]                  from /home/jizz/code/gl/chetris/src/core/c_block.cpp:1:
[build] /home/jizz/code/gl/chetris/vendor/fmt/include/fmt/core.h:1134:27: note: declared here
[build]    FMT_DEPRECATED iterator begin() { return out_; }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions