Skip to content

libfmt support #259

@Timple

Description

@Timple

Good day

Unfortunately we cannot leverage the power of std::format just yet as we're stuck on ubuntu 22.04 for now.

However, libfmt is the predecesor of this format. Supporting this can be done easily with this snippet:

#include <fmt/format.h>
#include <magic_enum.hpp>

template <typename E>
struct fmt::formatter<E, std::enable_if_t<std::is_enum_v<E>, char>> : fmt::formatter<std::string_view, char> {
  auto format(E e, format_context& ctx)
  {
    return formatter<string_view>::format(magic_enum::enum_name(e), ctx);
  }
};

Could this perhaps be included in this wonderful library? Similar to the std::format perhaps?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions