Open edelmanjm opened 5 days ago
Possibly related to https://github.com/fmtlib/fmt/issues/4058? Unfortunately my templating isn't strong enough to figure this out definitively; I tried adding the following but it didn't work:
#include <fmt/ranges.h>
...
template <typename E>
struct fmt::is_range<E, std::enable_if_t<std::is_enum_v<std::decay_t<E>> && magic_enum::customize::enum_format_enabled<E>(), char>> {
static constexpr const bool value = false;
};
As for the local compiler error I'm seeing, it's as follows (trimmed for brevity):
ranges.h:674:47: error: ambiguous template instantiation for ‘struct fmt::v11::formatter<std::byte, char, void>’
674 | formatter<remove_cvref_t<value_type>, Char> value_formatter_;
| ^~~~~~~~~~~~~~~~
format.h:3975:8: note: candidates are: ‘template<class T, class Char> struct fmt::v11::formatter<T, Char, typename std::enable_if<fmt::v11::detail::has_format_as<T>::value, void>::type> [with T = std::byte; Char = char]’
3975 | struct formatter<T, Char, enable_if_t<detail::has_format_as<T>::value>>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
magic_enum_format.hpp:86:13: note: ‘template<class E> struct fmt::v11::formatter<E, typename std::enable_if<(is_enum_v<typename std::decay<_Tp>::type> && enum_format_enabled<E>()), char>::type> [with E = std::byte]’
86 | struct fmt::formatter<E, std::enable_if_t<std::is_enum_v<std::decay_t<E>> && magic_enum::customize::enum_format_enabled<E>(), char>> : fmt::formatter<std::string_view> {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(Ported from a comment on #298)
Including both headers appears to result in a compiler error.
On Godbolt this appears to be a
magic_enum requires enum implementation and valid max and min.
(even though the default max and min should be sufficient, and it compiles fine as long asfmt/ranges.h
isn't included)On my local compiler with a more complex example, I get an ambiguous function error with the enum template showing as valid for a non-enum type (
std:vector<std::byte>
). I suspect this is closer to the actual error.Here's the failing example: with both
#include <fmt/ranges.h>
and#include <magic_enum/magic_enum_format.hpp>
, I get a compiler error.Removing
#include <fmt/ranges.h>
allows it to compileRemoving
#include <magic_enum/magic_enum_format.hpp>
also allows it to compile