Disable broken copy ctor of dynamic_format_arg_store
This commit is contained in:
parent
659de779e6
commit
be51ee1ceb
@ -146,14 +146,7 @@ class dynamic_format_arg_store
|
|||||||
constexpr dynamic_format_arg_store() = default;
|
constexpr dynamic_format_arg_store() = default;
|
||||||
|
|
||||||
constexpr dynamic_format_arg_store(
|
constexpr dynamic_format_arg_store(
|
||||||
const dynamic_format_arg_store<Context>& store)
|
const dynamic_format_arg_store<Context>& store) = delete;
|
||||||
:
|
|
||||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
|
|
||||||
basic_format_args<Context>(),
|
|
||||||
#endif
|
|
||||||
data_(store.data_),
|
|
||||||
named_info_(store.named_info_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
TEST(args_test, basic) {
|
TEST(args_test, basic) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.push_back(42);
|
store.push_back(42);
|
||||||
store.push_back("abc1");
|
store.push_back("abc1");
|
||||||
store.push_back(1.5f);
|
store.push_back(1.5f);
|
||||||
@ -19,7 +19,7 @@ TEST(args_test, basic) {
|
|||||||
|
|
||||||
TEST(args_test, strings_and_refs) {
|
TEST(args_test, strings_and_refs) {
|
||||||
// Unfortunately the tests are compiled with old ABI so strings use COW.
|
// Unfortunately the tests are compiled with old ABI so strings use COW.
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
char str[] = "1234567890";
|
char str[] = "1234567890";
|
||||||
store.push_back(str);
|
store.push_back(str);
|
||||||
store.push_back(std::cref(str));
|
store.push_back(std::cref(str));
|
||||||
@ -48,7 +48,7 @@ template <> struct formatter<custom_type> {
|
|||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
|
|
||||||
TEST(args_test, custom_format) {
|
TEST(args_test, custom_format) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
auto c = custom_type();
|
auto c = custom_type();
|
||||||
store.push_back(c);
|
store.push_back(c);
|
||||||
++c.i;
|
++c.i;
|
||||||
@ -77,7 +77,7 @@ template <> struct formatter<to_stringable> {
|
|||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
|
|
||||||
TEST(args_test, to_string_and_formatter) {
|
TEST(args_test, to_string_and_formatter) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
auto s = to_stringable();
|
auto s = to_stringable();
|
||||||
store.push_back(s);
|
store.push_back(s);
|
||||||
store.push_back(std::cref(s));
|
store.push_back(std::cref(s));
|
||||||
@ -85,13 +85,13 @@ TEST(args_test, to_string_and_formatter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(args_test, named_int) {
|
TEST(args_test, named_int) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.push_back(fmt::arg("a1", 42));
|
store.push_back(fmt::arg("a1", 42));
|
||||||
EXPECT_EQ("42", fmt::vformat("{a1}", store));
|
EXPECT_EQ("42", fmt::vformat("{a1}", store));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(args_test, named_strings) {
|
TEST(args_test, named_strings) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
char str[] = "1234567890";
|
char str[] = "1234567890";
|
||||||
store.push_back(fmt::arg("a1", str));
|
store.push_back(fmt::arg("a1", str));
|
||||||
store.push_back(fmt::arg("a2", std::cref(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) {
|
TEST(args_test, named_arg_by_ref) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
char band[] = "Rolling Stones";
|
char band[] = "Rolling Stones";
|
||||||
store.push_back(fmt::arg("band", std::cref(band)));
|
store.push_back(fmt::arg("band", std::cref(band)));
|
||||||
band[9] = 'c'; // Changing band affects the output.
|
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) {
|
TEST(args_test, named_custom_format) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
auto c = custom_type();
|
auto c = custom_type();
|
||||||
store.push_back(fmt::arg("c1", c));
|
store.push_back(fmt::arg("c1", c));
|
||||||
++c.i;
|
++c.i;
|
||||||
@ -121,7 +121,7 @@ TEST(args_test, named_custom_format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(args_test, clear) {
|
TEST(args_test, clear) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.push_back(42);
|
store.push_back(42);
|
||||||
|
|
||||||
auto result = fmt::vformat("{}", store);
|
auto result = fmt::vformat("{}", store);
|
||||||
@ -138,7 +138,7 @@ TEST(args_test, clear) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(args_test, reserve) {
|
TEST(args_test, reserve) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.reserve(2, 1);
|
store.reserve(2, 1);
|
||||||
store.push_back(1.5f);
|
store.push_back(1.5f);
|
||||||
store.push_back(fmt::arg("a1", 42));
|
store.push_back(fmt::arg("a1", 42));
|
||||||
@ -163,7 +163,7 @@ template <> struct formatter<copy_throwable> {
|
|||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
|
|
||||||
TEST(args_test, throw_on_copy) {
|
TEST(args_test, throw_on_copy) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.push_back(std::string("foo"));
|
store.push_back(std::string("foo"));
|
||||||
try {
|
try {
|
||||||
store.push_back(copy_throwable());
|
store.push_back(copy_throwable());
|
||||||
@ -171,16 +171,3 @@ TEST(args_test, throw_on_copy) {
|
|||||||
}
|
}
|
||||||
EXPECT_EQ(fmt::vformat("{}", store), "foo");
|
EXPECT_EQ(fmt::vformat("{}", store), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(args_test, copy_constructor) {
|
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user