1717
1818
1919
20- // C++ includes
21-
2220// Local includes
2321#include "libmesh/dof_object.h"
2422
25-
2623namespace libMesh
2724{
2825
29-
30-
3126// ------------------------------------------------------------
3227// DofObject class static member -now initialized in header
3328const dof_id_type DofObject ::invalid_id ;
@@ -36,14 +31,9 @@ const processor_id_type DofObject::invalid_processor_id;
3631
3732
3833
39- // ------------------------------------------------------------
40- // DofObject class members
4134// Copy Constructor
4235DofObject ::DofObject (const DofObject & dof_obj ) :
4336 ReferenceCountedObject < DofObject > ( ),
44- #ifdef LIBMESH_ENABLE_AMR
45- old_dof_object (nullptr ),
46- #endif
4737#ifdef LIBMESH_ENABLE_UNIQUE_ID
4838 _unique_id (dof_obj ._unique_id ),
4939#endif
@@ -56,9 +46,6 @@ DofObject::DofObject (const DofObject & dof_obj) :
5646 // is intended to be used solely for internal construction of
5747 // old_dof_object, never for a true deep copy where the newly
5848 // created object really matches the source object.
59- //
60- // if (dof_obj.old_dof_object)
61- // this->old_dof_object = new DofObject(*(dof_obj.old_dof_object));
6249
6350 // Check that everything worked
6451#ifdef DEBUG
@@ -95,7 +82,10 @@ DofObject & DofObject::operator= (const DofObject & dof_obj)
9582#ifdef LIBMESH_ENABLE_AMR
9683 this -> clear_old_dof_object ();
9784
98- this -> old_dof_object = new DofObject (* (dof_obj .old_dof_object ));
85+ // Note: we can't use std::make_unique here because the DofObject
86+ // copy constructor is private, and std::make_unique effectively
87+ // calls "placement new" which requires a public constructor.
88+ this -> old_dof_object = std ::unique_ptr < DofObject > (new DofObject (* dof_obj .old_dof_object ));
9989#endif
10090
10191 _id = dof_obj ._id ;
@@ -141,8 +131,7 @@ DofObject & DofObject::operator= (const DofObject & dof_obj)
141131
142132void DofObject ::clear_old_dof_object ()
143133{
144- delete this -> old_dof_object ;
145- this -> old_dof_object = nullptr ;
134+ this -> old_dof_object .reset (nullptr );
146135}
147136
148137
@@ -153,9 +142,10 @@ void DofObject::set_old_dof_object ()
153142
154143 libmesh_assert (!this -> old_dof_object );
155144
156- // Make a new DofObject, assign a copy of \p this.
157- // Make sure the copy ctor for DofObject works!!
158- this -> old_dof_object = new DofObject (* this );
145+ // Note: we can't use std::make_unique here because the DofObject
146+ // copy constructor is private, and std::make_unique effectively
147+ // calls "placement new" which requires a public constructor.
148+ this -> old_dof_object = std ::unique_ptr < DofObject > (new DofObject (* this ));
159149}
160150
161151#endif
@@ -644,7 +634,7 @@ void DofObject::unpack_indexing(std::vector<largest_id_type>::const_iterator beg
644634#ifdef LIBMESH_ENABLE_AMR
645635 if (has_old_dof_object )
646636 {
647- this -> old_dof_object = new DofObject ();
637+ this -> old_dof_object = std :: unique_ptr < DofObject > ( new DofObject () );
648638 this -> old_dof_object -> unpack_indexing (begin + size );
649639 }
650640#endif
0 commit comments