From be51ee1ceb0553411cae166335b59e7ae5126527 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 17 Dec 2021 17:13:08 -0800 Subject: [PATCH] Disable broken copy ctor of dynamic_format_arg_store --- include/fmt/args.h | 9 +-------- test/args-test.cc | 35 +++++++++++------------------------ 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/include/fmt/args.h b/include/fmt/args.h index 36f62220..99060040 100644 --- a/include/fmt/args.h +++ b/include/fmt/args.h @@ -146,14 +146,7 @@ class dynamic_format_arg_store constexpr dynamic_format_arg_store() = default; constexpr dynamic_format_arg_store( - const dynamic_format_arg_store& store) - : -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 - basic_format_args(), -#endif - data_(store.data_), - named_info_(store.named_info_) { - } + const dynamic_format_arg_store& store) = delete; /** \rst diff --git a/test/args-test.cc b/test/args-test.cc index 2b1db8c8..e793cb5c 100644 --- a/test/args-test.cc +++ b/test/args-test.cc @@ -10,7 +10,7 @@ #include "gtest/gtest.h" TEST(args_test, basic) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; store.push_back(42); store.push_back("abc1"); store.push_back(1.5f); @@ -19,7 +19,7 @@ TEST(args_test, basic) { TEST(args_test, strings_and_refs) { // Unfortunately the tests are compiled with old ABI so strings use COW. - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; char str[] = "1234567890"; store.push_back(str); store.push_back(std::cref(str)); @@ -48,7 +48,7 @@ template <> struct formatter { FMT_END_NAMESPACE TEST(args_test, custom_format) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; auto c = custom_type(); store.push_back(c); ++c.i; @@ -77,7 +77,7 @@ template <> struct formatter { FMT_END_NAMESPACE TEST(args_test, to_string_and_formatter) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; auto s = to_stringable(); store.push_back(s); store.push_back(std::cref(s)); @@ -85,13 +85,13 @@ TEST(args_test, to_string_and_formatter) { } TEST(args_test, named_int) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; store.push_back(fmt::arg("a1", 42)); EXPECT_EQ("42", fmt::vformat("{a1}", store)); } TEST(args_test, named_strings) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; char str[] = "1234567890"; store.push_back(fmt::arg("a1", str)); store.push_back(fmt::arg("a2", std::cref(str))); @@ -100,7 +100,7 @@ TEST(args_test, named_strings) { } TEST(args_test, named_arg_by_ref) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; char band[] = "Rolling Stones"; store.push_back(fmt::arg("band", std::cref(band))); band[9] = 'c'; // Changing band affects the output. @@ -108,7 +108,7 @@ TEST(args_test, named_arg_by_ref) { } TEST(args_test, named_custom_format) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; auto c = custom_type(); store.push_back(fmt::arg("c1", c)); ++c.i; @@ -121,7 +121,7 @@ TEST(args_test, named_custom_format) { } TEST(args_test, clear) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; store.push_back(42); auto result = fmt::vformat("{}", store); @@ -138,7 +138,7 @@ TEST(args_test, clear) { } TEST(args_test, reserve) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; store.reserve(2, 1); store.push_back(1.5f); store.push_back(fmt::arg("a1", 42)); @@ -163,7 +163,7 @@ template <> struct formatter { FMT_END_NAMESPACE TEST(args_test, throw_on_copy) { - auto store = fmt::dynamic_format_arg_store(); + fmt::dynamic_format_arg_store store; store.push_back(std::string("foo")); try { store.push_back(copy_throwable()); @@ -171,16 +171,3 @@ TEST(args_test, throw_on_copy) { } EXPECT_EQ(fmt::vformat("{}", store), "foo"); } - -TEST(args_test, copy_constructor) { - auto store = fmt::dynamic_format_arg_store(); - store.push_back(fmt::arg("test1", "value1")); - store.push_back(fmt::arg("test2", "value2")); - store.push_back(fmt::arg("test3", "value3")); - - auto store2 = store; - store2.push_back(fmt::arg("test4", "value4")); - - auto result = fmt::vformat("{test1} {test2} {test3} {test4}", store2); - EXPECT_EQ(result, "value1 value2 value3 value4"); -}