fmt
fmt copied to clipboard
`std::filesystem::path` with `fmt::printf()`
std::filesystem::path seems to give a compile error for fmt::printf() but not for fmt::print():
#include <filesystem>
#include <fmt/std.h>
#include <fmt/printf.h>
void f(){
std::filesystem::path p;
fmt::print("{}", p); // compiles
fmt::printf("%s", p); // doesn't compile
}
Compiler error
In file included from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/format.h:41,
from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/std.h:11,
from <source>:3:
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h: In instantiation of 'constexpr fmt::v11::detail::value<Context> fmt::v11::detail::make_arg(T&) [with bool PACKED = true; Context = fmt::v11::basic_printf_context<char>; T = const std::filesystem::__cxx11::path; typename std::enable_if<PACKED, int>::type <anonymous> = 0]':
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:2026:74: required from 'constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = basic_printf_context<char>; T = {const std::filesystem::__cxx11::path}; long unsigned int NUM_ARGS = 1; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 15; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]'
2026 | return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>(
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
2027 | args)...}};
| ~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/printf.h:575:59: required from 'decltype (make_format_args<fmt::v11::basic_printf_context<Char> >(fmt::v11::make_printf_args::args ...)) fmt::v11::make_printf_args(T& ...) [with Char = char; T = {const std::filesystem::__cxx11::path}; decltype (make_format_args<basic_printf_context<Char> >(fmt::v11::make_printf_args::args ...)) = detail::format_arg_store<basic_printf_context<char>, 1, 0, 15>]'
575 | return fmt::make_format_args<basic_printf_context<Char>>(args...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/printf.h:647:48: required from 'int fmt::v11::printf(string_view, const T& ...) [with T = {std::filesystem::__cxx11::path}; string_view = basic_string_view<char>]'
647 | return vfprintf(stdout, fmt, make_printf_args(args...));
| ~~~~~~~~~~~~~~~~^~~~~~~~~
<source>:9:16: required from here
9 | fmt::printf("%s", p); // doesn't compile
| ~~~~~~~~~~~^~~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:1650:63: error: 'fmt::v11::detail::type_is_unformattable_for<const std::filesystem::__cxx11::path, char> _' has incomplete type
1650 | type_is_unformattable_for<T, typename Context::char_type> _;
| ^
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:1653: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
1653 | formattable,
| ^~~~~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:1653:7: note: 'formattable' evaluates to false
Compiler returned: 1
I'm a new fmt user, apologies if this is intended behavior. Thanks for the excellent package!