File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -2540,3 +2540,33 @@ TEST(base_test, format_byte) {
25402540 EXPECT_EQ (s, " 42" );
25412541}
25422542#endif
2543+
2544+ // Only defined after the test case.
2545+ struct incomplete_type ;
2546+ extern const incomplete_type& external_instance;
2547+
2548+ FMT_BEGIN_NAMESPACE
2549+
2550+ template <> struct formatter <incomplete_type> : formatter<int > {
2551+ auto format (const incomplete_type& x, context& ctx) const
2552+ -> decltype(ctx.out());
2553+ };
2554+
2555+ FMT_END_NAMESPACE
2556+
2557+ TEST (incomplete_type_test, format) {
2558+ EXPECT_EQ (fmt::format (" {}" , external_instance), fmt::format (" {}" , 42 ));
2559+ EXPECT_EQ (fmt::format (" {:4}" , external_instance), fmt::format (" {:4}" , 42 ));
2560+ }
2561+
2562+ struct incomplete_type {
2563+ int i;
2564+ };
2565+
2566+ const incomplete_type& external_instance{42 };
2567+
2568+ auto fmt::formatter<incomplete_type>::format(const incomplete_type& x,
2569+ fmt::context& ctx) const
2570+ -> decltype (ctx.out()) {
2571+ return fmt::formatter<int >::format (x.i , ctx);
2572+ }
You can’t perform that action at this time.
0 commit comments