Skip to content

Broken support for printing abstract classes with ostream adapter #2439

Description

@PiotrZSL

ENV: GCC 10 + FMT 8.0.1 (master) + FMT_COMPILE + fmt::format_to + reference to abstract class as argument.
Abstract class got friend operator <<.

Result: Compilation fails.
Issue looks to be caused by std::numeric_limits.
Fails with: limits:317:7: error: invalid abstract return type ‘'.

Workaround:
format.h (ignored is_fast_float for classes)

 567 template<typename T, bool = std::is_class<T>::value>
 568 struct Workaround : std::false_type
 569 {
 570 };
 571
 572 template<typename T>
 573 struct Workaround<T, false> : bool_constant<std::numeric_limits<T>::is_iec559 && sizeof(T) <= sizeof(double)>
 574 {
 575
 576 };
 577
 578 template <typename T>
 579 using is_fast_float = Workaround<T>;

ostream.h (added & to std::declval to create reference to type instead of rvalue).

 75 template <typename T, typename Char> class is_streamable {
 76  private:
 77   template <typename U>
 78   static bool_constant<!std::is_same<decltype(std::declval<test_stream<Char>&>()
 79                                               << std::declval<U&>()),
 80                                      void_t<>>::value>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions