Codechange: Switch DropDownList to directly use std::vector, thus making AutoDeleteSmallVector obsolete.

DropDownListItem are strongly managed using std::unique_ptr to ensure leak-free handling. Appropriate use
of move-semantics make intent a lot clearer than parameter comments and allows the compiler to generate
copy-free code for most situations.
This commit is contained in:
Michael Lutz
2019-04-02 21:31:24 +02:00
parent d3e113eb5f
commit c7b9987d08
22 changed files with 184 additions and 253 deletions

View File

@@ -99,36 +99,6 @@ public:
}
};
/**
* Simple vector template class, with automatic delete.
*
* @note There are no asserts in the class so you have
* to care about that you grab an item which is
* inside the list.
*
* @param T The type of the items stored, must be a pointer
*/
template <typename T>
class AutoDeleteSmallVector : public std::vector<T> {
public:
~AutoDeleteSmallVector()
{
this->Clear();
}
/**
* Remove all items from the list.
*/
inline void Clear()
{
for (T p : *this) {
delete p;
}
std::vector<T>::clear();
}
};
typedef AutoFreeSmallVector<char*> StringList; ///< Type for a list of strings.
#endif /* SMALLVEC_TYPE_HPP */