Skip to content

Commit

Permalink
Add virtual destructors to StateVector classes (#200)
Browse files Browse the repository at this point in the history
* Add virtual destructors to StateVector classes

* Update changelog

* Remove second virtual

* Follow isocpp/CppCoreGuidelines#721 consensus and use override in dtor
  • Loading branch information
mlxd authored Dec 21, 2021
1 parent 978f739 commit 17d895f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Direct support to probability, expectation value and variance calculation in PL-Lightning.
[(#185)](https://github.com/PennyLaneAI/pennylane-lightning/pull/185)

* Add C++ only benchmark for a given list of gates ([#199](https://github.com/PennyLaneAI/pennylane-lightning/pull/199))
* Add C++ only benchmark for a given list of gates.
[(#199)](https://github.com/PennyLaneAI/pennylane-lightning/pull/199)

### Breaking changes

Expand All @@ -14,6 +15,9 @@

### Bug fixes

* Add virtual destructor to C++ state-vector classes.
[(#200)](https://github.com/PennyLaneAI/pennylane-lightning/pull/200)

### Contributors

This release contains contributions from (in alphabetical order):
Expand Down
2 changes: 2 additions & 0 deletions pennylane_lightning/src/simulator/StateVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ template <class fp_t = double> class StateVector {
std::forward<decltype(PH4)>(PH4));
}}} {};

virtual ~StateVector() = default;

/**
* @brief Get the underlying data pointer.
*
Expand Down
2 changes: 2 additions & 0 deletions pennylane_lightning/src/simulator/StateVectorManaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class StateVectorManaged : public StateVector<fp_t> {
StateVector<fp_t>::setData(data_.data());
}

~StateVectorManaged() override = default;

auto operator=(const StateVectorManaged<fp_t> &other)
-> StateVectorManaged & {
if (this != &other) {
Expand Down

0 comments on commit 17d895f

Please sign in to comment.