diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 8cf3e3411..8531695f9 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -514,7 +514,20 @@ namespace diff{ /** prevent moving into black hole */ RecordRef(Target&&) = delete; - // standard copy operations acceptable + RecordRef(RecordRef const&) = default; + RecordRef(RecordRef &&) = default; + + /** references can not be reassigned */ + RecordRef& operator= (RecordRef const&) = delete; + RecordRef& operator= (RecordRef &) = delete; + + /** assignment is not allowed, but moving is */ + RecordRef& + operator= (RecordRef &&o) + { + std::swap(record_, o.record_); + return *this; + } explicit diff --git a/tests/library/diff/generic-record-representation-test.cpp b/tests/library/diff/generic-record-representation-test.cpp index 1eac8e22b..1c65a8c62 100644 --- a/tests/library/diff/generic-record-representation-test.cpp +++ b/tests/library/diff/generic-record-representation-test.cpp @@ -326,12 +326,13 @@ namespace test{ CHECK ("🌰" == oor.getType()); CHECK (oor.get("♄") == "saturn"); - // are copyable and assignable + // are copyable but not reassignable RecordRef r2 = ref; CHECK (r2); CHECK (r2.get() == ref.get()); CHECK (!isSameObject (r2, ref)); + // but references are move-assignable empty = std::move(r2); CHECK (empty); CHECK (!r2);