We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
to_string_view
FMT_COMPILE
Similar to #2180 in outcome but I think underlying cause might be different. https://gcc.godbolt.org/z/rWKEM6
#include <fmt/args.h> #include <fmt/compile.h> #include <fmt/format.h> #include <iostream> #include <string> #include <string_view> struct UserType { std::string name; #ifdef HAS_TO_STRING_VIEW friend std::string_view to_string_view(const UserType& ut) { return ut.name; } #endif }; template <> struct fmt::formatter<UserType> : fmt::formatter<std::string_view> { using B = fmt::formatter<std::string_view>; using B::parse; template <typename FC> auto format(const UserType& ut, FC& fc) { return B::format(std::string_view{ut.name}, fc); } }; void print(const std::string& s) { std::cout << s << std::endl; } int main() { UserType ut{"Alice"}; print(fmt::format(FMT_COMPILE("[{}]"), ut)); return 0; }
Fails only if HAS_TO_STRING_VIEW is defined. (see godbolt link for full failure output).
HAS_TO_STRING_VIEW
In file included from <source>:2: /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h: In instantiation of 'constexpr OutputIt fmt::v7::detail::field<Char, T, N>::format(OutputIt, const Args& ...) const [with OutputIt = fmt::v7::detail::buffer_appender<char>; Args = {UserType}; Char = char; T = UserType; int N = 0]': /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h:612:21: required from 'constexpr OutputIt fmt::v7::detail::concat<L, R>::format(OutputIt, const Args& ...) const [with OutputIt = fmt::v7::detail::buffer_appender<char>; Args = {UserType}; L = fmt::v7::detail::field<char, UserType, 0>; R = fmt::v7::detail::code_unit<char>]' /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h:613:22: required from 'constexpr OutputIt fmt::v7::detail::concat<L, R>::format(OutputIt, const Args& ...) const [with OutputIt = fmt::v7::detail::buffer_appender<char>; Args = {UserType}; L = fmt::v7::detail::code_unit<char>; R = fmt::v7::detail::concat<fmt::v7::detail::field<char, UserType, 0>, fmt::v7::detail::code_unit<char> >]' /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h:827:3: required from 'std::__cxx11::basic_string<Char> fmt::v7::format(const CompiledFormat&, const Args& ...) [with CompiledFormat = fmt::v7::detail::concat<fmt::v7::detail::code_unit<char>, fmt::v7::detail::concat<fmt::v7::detail::field<char, UserType, 0>, fmt::v7::detail::code_unit<char> > >; Args = {UserType}; Char = char; typename std::enable_if<fmt::v7::detail::is_compiled_format<T>::value, int>::type <anonymous> = 0]' /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h:877:18: required from 'std::__cxx11::basic_string<typename Context::char_type> fmt::v7::format(const S&, Args&& ...) [with S = main()::<lambda()>::FMT_COMPILE_STRING; Args = {UserType&}; typename std::enable_if<fmt::v7::detail::is_compiled_string<S>::value, int>::type <anonymous> = 0; typename Context::char_type = char; typename Context::char_type = char]' <source>:31:44: required from here /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h:546:25: error: no matching function for call to 'write<char>(fmt::v7::detail::buffer_appender<char>&, const UserType&)' 546 | return write<Char>(out, arg); | ~~~~~~~~~~~^~~~~~~~~~ In file included from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/compile.h:14, from <source>:2: /opt/compiler-explorer/libs/fmt/trunk/include/fmt/format.h:1789:24: note: candidate: 'template<class OutputIt, class StrChar, class Char> constexpr OutputIt fmt::v7::detail::write(OutputIt, fmt::v7::basic_string_view<Char>, const fmt::v7::basic_format_specs<Char>&)' 1789 | FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view<StrChar> s, | ^~~~~
The text was updated successfully, but these errors were encountered:
dynamic_format_arg_store
Fix handling of formattable types with to_string_view (#2181)
14a2a64
Fixed in 14a2a64. Thanks for reporting.
Sorry, something went wrong.
No branches or pull requests
Similar to #2180 in outcome but I think underlying cause might be different.
https://gcc.godbolt.org/z/rWKEM6
Fails only if
HAS_TO_STRING_VIEW
is defined.(see godbolt link for full failure output).
The text was updated successfully, but these errors were encountered: