Skip to content

Commit

Permalink
Add move constructor to custom types
Browse files Browse the repository at this point in the history
  • Loading branch information
jandrej committed Jun 12, 2020
1 parent 7690eca commit 1875c34
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions miniapps/navier/navier_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class VelDirichletBC_T
: attr(attr), coeff(coeff)
{}

VelDirichletBC_T(VelDirichletBC_T &&obj)
{
// Deep copy the attribute array
this->attr = obj.attr;

// Move the coefficient pointer
this->coeff = obj.coeff;
obj.coeff = nullptr;
}

~VelDirichletBC_T() { delete coeff; }

Array<int> attr;
Expand All @@ -46,6 +56,16 @@ class PresDirichletBC_T
: attr(attr), coeff(coeff)
{}

PresDirichletBC_T(PresDirichletBC_T &&obj)
{
// Deep copy the attribute array
this->attr = obj.attr;

// Move the coefficient pointer
this->coeff = obj.coeff;
obj.coeff = nullptr;
}

~PresDirichletBC_T() { delete coeff; }

Array<int> attr;
Expand All @@ -60,6 +80,16 @@ class AccelTerm_T
: attr(attr), coeff(coeff)
{}

AccelTerm_T(AccelTerm_T &&obj)
{
// Deep copy the attribute array
this->attr = obj.attr;

// Move the coefficient pointer
this->coeff = obj.coeff;
obj.coeff = nullptr;
}

~AccelTerm_T() { delete coeff; }

Array<int> attr;
Expand Down

0 comments on commit 1875c34

Please sign in to comment.