Skip to content

Commit

Permalink
Fixed clang compilation warnings about delete GrandOrgue#2001
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg68 committed Nov 30, 2024
1 parent 719c1a1 commit 4f59f50
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/ptrvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ template <class T> class ptr_vector : protected std::vector<T *> {
template <
typename T1,
std::enable_if_t<std::is_array<T1>::value, bool> = true>
inline static void destroyE(T1 *e) {
inline static void delete0(T1 *e) {
delete[] e;
}

template <
typename T1,
std::enable_if_t<std::is_array<T1>::value, bool> = false>
inline static void destroyE(T1 *e) {
std::enable_if_t<!std::is_array<T1>::value, bool> = true>
inline static void delete0(T1 *e) {
delete e;
}

inline static void deleteEl(T *e) {
inline static void delete1(T *e) {
if (e)
destroyE<T>(e);
delete0(e);
}

public:
Expand All @@ -43,7 +43,7 @@ template <class T> class ptr_vector : protected std::vector<T *> {

~ptr_vector() {
for (auto &e : (*this))
deleteEl(e);
delete1(e);
}

T *&operator[](unsigned pos) { return at(pos); }
Expand All @@ -61,7 +61,7 @@ template <class T> class ptr_vector : protected std::vector<T *> {
void resize(unsigned new_size) {
unsigned oldsize = size();
for (unsigned i = new_size; i < oldsize; i++)
deleteEl(at(i));
delete1(at(i));
std::vector<T *>::resize(new_size);
for (unsigned i = oldsize; i < new_size; i++)
at(i) = nullptr;
Expand Down

0 comments on commit 4f59f50

Please sign in to comment.