Skip to content
Snippets Groups Projects
Commit 2383e8e3 authored by Lasse Hinrichsen-Bischoff's avatar Lasse Hinrichsen-Bischoff Committed by Simon Praetorius
Browse files

[VariableBlockVector] Move constructor and assignment

parent 1efccb40
No related branches found
No related tags found
1 merge request!463Cleanup the VariableBlockVector implementation
......@@ -87,5 +87,10 @@ int main()
testVectorSpaceOperations(v5);
testScalarProduct(v5);
// check move construction
auto v6 = std::move(v4);
suite.check(v6.size()==20, "Check size of moved-constructed object");
suite.check(v6[0].size() == 8, "Check if blocksize of move constructed vector survived");
return suite.exit();
}
......@@ -146,6 +146,25 @@ namespace Dune {
~VariableBlockVector() = default;
void swap(VariableBlockVector& other) {
std::swap(storage_, other.storage_);
std::swap(block, other.block);
std::swap(initialized, other.initialized);
other.syncBaseArray();
syncBaseArray();
}
// move constructor:
VariableBlockVector(VariableBlockVector&& tmp) {
swap(tmp);
}
// move assignment
VariableBlockVector& operator=(VariableBlockVector&& tmp) {
swap(tmp);
return *this;
}
//! same effect as constructor with same argument
void resize (size_type _nblocks)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment