Skip to content

Commit

Permalink
Fixed -Wdeprecated-copy-dtor warnings by implementing a copy assignme…
Browse files Browse the repository at this point in the history
…nt operator

Example warning was:

warning: definition of implicit copy assignment operator for 'Group' is deprecated because it has a user-declared destructor [-Wdeprecated-copy-dtor]
  • Loading branch information
seanm committed Sep 19, 2023
1 parent 95907ba commit 6e7ada5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions c++/src/H5Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,16 @@ Attribute::~Attribute()
}
}

//--------------------------------------------------------------------------
// Function: Copy assignment operator
Attribute &
Attribute::operator=(const Attribute &original)
{
if (&original != this) {
setId(original.id);
}

return *this;
}

} // namespace H5
3 changes: 3 additions & 0 deletions c++/src/H5Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location {
// Destructor: properly terminates access to this attribute.
virtual ~Attribute() override;

// Copy assignment operator.
Attribute &operator=(const Attribute &original);

#ifndef DOXYGEN_SHOULD_SKIP_THIS
protected:
// Sets the attribute id.
Expand Down
12 changes: 12 additions & 0 deletions c++/src/H5Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,16 @@ Group::~Group()
}
}

//--------------------------------------------------------------------------
// Function: Copy assignment operator
Group &
Group::operator=(const Group &original)
{
if (&original != this) {
setId(original.id);
}

return *this;
}

} // namespace H5
3 changes: 3 additions & 0 deletions c++/src/H5Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Destructor
virtual ~Group() override;

// Copy assignment operator.
Group &operator=(const Group &original);

// Creates a copy of an existing group using its id.
Group(const hid_t group_id);

Expand Down

0 comments on commit 6e7ada5

Please sign in to comment.