Commit 24d5567c authored by Kenton Varda's avatar Kenton Varda

Fix bug where DynamicValue::Builder was not assignable.

parent a86b5f24
......@@ -439,6 +439,24 @@ TEST(DynamicApi, SetDataFromText) {
EXPECT_EQ(data("foo"), root.get("dataField").as<Data>());
}
TEST(DynamicApi, BuilderAssign) {
MallocMessageBuilder builder;
auto root = builder.initRoot<DynamicStruct>(Schema::from<TestAllTypes>());
// Declare upfront, assign later.
DynamicValue::Builder value;
DynamicStruct::Builder structValue = nullptr;
DynamicList::Builder listValue = nullptr;
value = root.get("structField");
structValue = value.as<DynamicStruct>();
structValue.set("int32Field", 123);
value = root.init("int32List", 1);
listValue = value.as<DynamicList>();
listValue.set(0, 123);
}
} // namespace
} // namespace _ (private)
} // namespace capnp
......@@ -613,6 +613,8 @@ public:
inline Builder(Builder& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder(Builder&& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder& operator=(Builder& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder& operator=(Builder&& other) { memcpy(this, &other, sizeof(*this)); }
static_assert(__has_trivial_copy(StructSchema) && __has_trivial_copy(ListSchema),
"Assumptions made here do not hold.");
// Hack: We know this type is trivially constructable but the use of DisallowConstCopy causes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment