[PATCH] D34463: bug33388 - Fix formatv_objet copy & move constructors
Benoit Belley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 9 06:47:59 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310475: [Support] PR33388 - Fix formatv_object move constructor (authored by belleyb).
Changed prior to commit:
https://reviews.llvm.org/D34463?vs=103623&id=110382#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34463
Files:
llvm/trunk/include/llvm/Support/FormatVariadic.h
llvm/trunk/unittests/Support/FormatVariadicTest.cpp
Index: llvm/trunk/unittests/Support/FormatVariadicTest.cpp
===================================================================
--- llvm/trunk/unittests/Support/FormatVariadicTest.cpp
+++ llvm/trunk/unittests/Support/FormatVariadicTest.cpp
@@ -553,6 +553,12 @@
formatv("{0,=34:X-}", fmt_repeat(fmt_pad(N, 1, 3), 5)).str());
}
+TEST(FormatVariadicTest, MoveConstructor) {
+ auto fmt = formatv("{0} {1}", 1, 2);
+ auto fmt2 = std::move(fmt);
+ std::string S = fmt2;
+ EXPECT_EQ("1 2", S);
+}
TEST(FormatVariadicTest, ImplicitConversions) {
std::string S = formatv("{0} {1}", 1, 2);
EXPECT_EQ("1 2", S);
Index: llvm/trunk/include/llvm/Support/FormatVariadic.h
===================================================================
--- llvm/trunk/include/llvm/Support/FormatVariadic.h
+++ llvm/trunk/include/llvm/Support/FormatVariadic.h
@@ -94,6 +94,15 @@
Adapters.reserve(ParamCount);
}
+ formatv_object_base(formatv_object_base const &rhs) = delete;
+
+ formatv_object_base(formatv_object_base &&rhs)
+ : Fmt(std::move(rhs.Fmt)),
+ Adapters(), // Adapters are initialized by formatv_object
+ Replacements(std::move(rhs.Replacements)) {
+ Adapters.reserve(rhs.Adapters.size());
+ };
+
void format(raw_ostream &S) const {
for (auto &R : Replacements) {
if (R.Type == ReplacementType::Empty)
@@ -149,6 +158,14 @@
Parameters(std::move(Params)) {
Adapters = apply_tuple(create_adapters(), Parameters);
}
+
+ formatv_object(formatv_object const &rhs) = delete;
+
+ formatv_object(formatv_object &&rhs)
+ : formatv_object_base(std::move(rhs)),
+ Parameters(std::move(rhs.Parameters)) {
+ Adapters = apply_tuple(create_adapters(), Parameters);
+ }
};
// \brief Format text given a format string and replacement parameters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34463.110382.patch
Type: text/x-patch
Size: 1826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170809/62545cf7/attachment.bin>
More information about the llvm-commits
mailing list