fmt 9 added support for fmt::to_string(__float128)
but no formatter yet as far as I know. I've tried to make my own like below, but this failed:
#include <fmt/core.h> #include <fmt/std.h> template <> struct fmt::formatter<__float128> : fmt::formatter<std::string> { template <typename FormatContext> auto format(__float128 number, FormatContext& ctx) const { return fmt::formatter<std::string>::format(fmt::to_string(number), ctx); } }; int main() { fmt::format("{}", __float128{1.3}); }
Am I doing something wrong or is this a bug?
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h: In substitution of 'template<class T, class Context> using mapped_type_constant = fmt::v10::detail::type_constant<decltype (fmt::v10::detail::arg_mapper<Context>().map(declval<const T&>())), typename Context::char_type> [with T = __float128; Context = fmt::v10::basic_format_context<fmt::v10::appender, char>]':
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:2588:66: required from 'constexpr fmt::v10::detail::format_string_checker<Char, Args>::format_string_checker(fmt::v10::basic_string_view<Char>) [with Char = char; Args = {__float128}]'
<source>:13:16: required from here
<source>:13:16: in 'constexpr' expansion of 'fmt::v10::basic_format_string<char, __float128>("{}")'
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1475:53: error: call of overloaded 'map(const __float128&)' is ambiguous
1475 | type_constant<decltype(arg_mapper<Context>().map(std::declval<const T&>())),
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
...
The error is very long, so I won't post all of it here. See https://godbolt.org/z/9GPM5MGvG for full output.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4