mirror of
https://github.com/fmtlib/fmt.git
synced 2025-04-15 20:42:27 +00:00
Fix formatting of abstract classes via ostream
This commit is contained in:
parent
8029bf955c
commit
ee0659f8b6
@ -579,9 +579,10 @@ inline auto code_point_index(basic_string_view<char8_type> s, size_t n)
|
|||||||
return s.size();
|
return s.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T, bool = std::is_floating_point<T>::value>
|
||||||
using is_fast_float = bool_constant<std::numeric_limits<T>::is_iec559 &&
|
struct is_fast_float : bool_constant<std::numeric_limits<T>::is_iec559 &&
|
||||||
sizeof(T) <= sizeof(double)>;
|
sizeof(T) <= sizeof(double)> {};
|
||||||
|
template <typename T> struct is_fast_float<T, false> : std::false_type {};
|
||||||
|
|
||||||
#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
|
#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
|
||||||
# define FMT_USE_FULL_CACHE_DRAGONBOX 0
|
# define FMT_USE_FULL_CACHE_DRAGONBOX 0
|
||||||
|
@ -23,6 +23,7 @@ template <> struct formatter<test> : formatter<int> {
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "fmt/compile.h"
|
||||||
#include "fmt/ostream.h"
|
#include "fmt/ostream.h"
|
||||||
#include "fmt/ranges.h"
|
#include "fmt/ranges.h"
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
@ -280,3 +281,15 @@ TEST(ostream_test, range) {
|
|||||||
auto strs = std::vector<test_string>{test_string("foo"), test_string("bar")};
|
auto strs = std::vector<test_string>{test_string("foo"), test_string("bar")};
|
||||||
EXPECT_EQ("[foo, bar]", fmt::format("{}", strs));
|
EXPECT_EQ("[foo, bar]", fmt::format("{}", strs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct abstract {
|
||||||
|
virtual ~abstract() = default;
|
||||||
|
virtual void f() = 0;
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const abstract&) {
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void format_abstract_compiles(const abstract& a) {
|
||||||
|
fmt::format(FMT_COMPILE("{}"), a);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user