Skip to content
New issue

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

Compile-time checking does not work with named argument of a custom type #2816

Closed
timsong-cpp opened this issue Mar 18, 2022 · 0 comments
Closed

Comments

@timsong-cpp
Copy link
Contributor

https://godbolt.org/z/haoG1o3Pq

#include <fmt/format.h>

struct E {};
template<>
struct fmt::formatter<E> : fmt::formatter<std::string_view> {
    auto format(E, auto& ctx) const { return fmt::formatter<std::string_view>::format("42", ctx); }
};

void f() {
    using namespace fmt::literals;
    (void) fmt::format("{a}", "a"_a = E());
}

with -std=c++2a/2b:

In file included from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/format.h:49,
                 from <source>:1:
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h: In instantiation of 'constexpr decltype (ctx.begin()) fmt::v8::detail::parse_format_specs(ParseContext&) [with T = statically_named_arg<E, char, 2, fmt::v8::detail_exported::fixed_string<char, 2>{"a"}>; ParseContext = compile_parse_context<char, error_handler>; decltype (ctx.begin()) = const char*]':
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:2894:22:   required from 'constexpr fmt::v8::detail::format_string_checker<Char, ErrorHandler, Args>::format_string_checker(fmt::v8::basic_string_view<Char>, ErrorHandler) [with Char = char; ErrorHandler = fmt::v8::detail::error_handler; Args = {fmt::v8::detail::statically_named_arg<E, char, 2, fmt::v8::detail_exported::fixed_string<char, 2>{"a"}>}]'
<source>:11:23:   required from here
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:2658:12: error: use of deleted function 'fmt::v8::detail::fallback_formatter<T, Char, Enable>::fallback_formatter() [with T = fmt::v8::detail::statically_named_arg<E, char, 2, fmt::v8::detail_exported::fixed_string<char, 2>{"a"}>; Char = char; Enable = void]'
 2658 |   auto f = conditional_t<has_formatter<mapped_type, context>::value,
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2659 |                          formatter<mapped_type, char_type>,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2660 |                          fallback_formatter<T, char_type>>();
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1013:3: note: declared here
 1013 |   fallback_formatter() = delete;
      |   ^~~~~~~~~~~~~~~~~~
Compiler returned: 1
@timsong-cpp timsong-cpp changed the title Compile-time checking does not work when named argument of a custom type Compile-time checking does not work with named argument of a custom type Mar 18, 2022
@vitaut vitaut closed this as completed in 3d19be2 Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant