From 73732e19e977a146578206532b8af79490f31c2e Mon Sep 17 00:00:00 2001 From: Luc Pelletier Date: Sat, 18 Dec 2021 11:55:22 -0500 Subject: [PATCH 1/3] Don't explicitly delete copy ctor of dynamic_format_arg_store Explicitly deleting the copy ctor causes the move constructor to not be implicitly generated. This behaviour is different than what was in v8.0.1 and causes code that relied on the move ctor of dynamic_format_arg_store to break. --- include/fmt/args.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/fmt/args.h b/include/fmt/args.h index 9906004098b9..9a8e4ed2cebb 100644 --- a/include/fmt/args.h +++ b/include/fmt/args.h @@ -145,9 +145,6 @@ class dynamic_format_arg_store public: constexpr dynamic_format_arg_store() = default; - constexpr dynamic_format_arg_store( - const dynamic_format_arg_store& store) = delete; - /** \rst Adds an argument into the dynamic store for later passing to a formatting From 18764e4ac308da093e849969ab749d53b9f2e7aa Mon Sep 17 00:00:00 2001 From: Luc Pelletier Date: Sun, 19 Dec 2021 12:33:04 -0500 Subject: [PATCH 2/3] Add test for dynamic_format_arg_store's move ctor --- test/args-test.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/args-test.cc b/test/args-test.cc index e793cb5c9ff4..32098dfb4d33 100644 --- a/test/args-test.cc +++ b/test/args-test.cc @@ -171,3 +171,21 @@ TEST(args_test, throw_on_copy) { } EXPECT_EQ(fmt::vformat("{}", store), "foo"); } + +TEST(args_test, move_constructor) { + const int test_integer = 42; + const char* const test_c_string = "foo"; + + auto store_uptr = + std::make_unique>(); + store_uptr->push_back(test_integer); + store_uptr->push_back(std::string(test_c_string)); + store_uptr->push_back(fmt::arg("a1", test_c_string)); + + fmt::dynamic_format_arg_store moved_store( + std::move(*store_uptr)); + store_uptr.reset(); + EXPECT_EQ( + fmt::vformat("{} {} {a1}", moved_store), + std::to_string(test_integer) + " " + test_c_string + " " + test_c_string); +} From 8e20ab57d365ec355b566392c43a0bf0be64cbc0 Mon Sep 17 00:00:00 2001 From: Luc Pelletier Date: Mon, 20 Dec 2021 14:34:37 -0500 Subject: [PATCH 3/3] include , don't use make_unique --- test/args-test.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/args-test.cc b/test/args-test.cc index 32098dfb4d33..d9afbc1aff21 100644 --- a/test/args-test.cc +++ b/test/args-test.cc @@ -7,6 +7,8 @@ #include "fmt/args.h" +#include + #include "gtest/gtest.h" TEST(args_test, basic) { @@ -176,8 +178,8 @@ TEST(args_test, move_constructor) { const int test_integer = 42; const char* const test_c_string = "foo"; - auto store_uptr = - std::make_unique>(); + std::unique_ptr> + store_uptr(new fmt::dynamic_format_arg_store()); store_uptr->push_back(test_integer); store_uptr->push_back(std::string(test_c_string)); store_uptr->push_back(fmt::arg("a1", test_c_string));