鉴于成功编纂的代码为fmt v9.1,但因fmt v10+
It tripped me a while before I found github issues with correct keywords enum
and compilation
. Also github issues are not stating version in title..
This is a defined behavior for fmt v10+
#include <iostream>
#include <fmt/core.h>
#include <fmt/ostream.h>
using Test = enum Test_e{
A,B,C
};
int main(int, char **)
{
fmt::print(std::cout, "test enum {}
", A);
}
When libfmt is upgraded to v10.0, following error messages pop up.:
Live Demo
Another live demo with better layout
Thanks to @Marek R
深层的相关问题
Error msg for C++11
In file included from <source>:2:
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/core.h: In instantiation of fmt::v10::detail::value<Context> fmt::v10::detail::make_value(T&&) [with Context = fmt::v10::basic_format_context<fmt::v10::appender, char>; T = Test_e&] :
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/core.h:1711:29: required from fmt::v10::detail::value<Context> fmt::v10::detail::make_arg(T&&) [with bool IS_PACKED = true; Context = fmt::v10::basic_format_context<fmt::v10::appender, char>; type <anonymous> = fmt::v10::detail::type::custom_type; T = Test_e&; typename std::enable_if<IS_PACKED, int>::type <anonymous> = 0]
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/core.h:1827:77: required from fmt::v10::format_arg_store<Context, Args>::format_arg_store(T&& ...) [with T = {Test_e&}; Context = fmt::v10::basic_format_context<fmt::v10::appender, char>; Args = {Test_e}]
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/core.h:1844:31: required from constexpr fmt::v10::format_arg_store<Context, typename std::remove_cv<typename std::remove_reference<T>::type>::type ...> fmt::v10::make_format_args(T&& ...) [with Context = basic_format_context<appender, char>; T = {Test_e&}]
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/ostream.h:179:44: required from void fmt::v10::print(std::ostream&, format_string<T ...>, T&& ...) [with T = {Test_e}; std::ostream = std::basic_ostream<char>; format_string<T ...> = basic_format_string<char, Test_e>]
<source>:10:15: required from here
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/core.h:1691:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt
1691 | formattable,
| ^~~~~~~~~~~
/opt/compiler-explorer/libs/fmt/10.0.0/include/fmt/core.h:1691:7: note: formattable evaluates to false
Compiler returned: 1