summaryrefslogtreecommitdiff
path: root/goo
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2018-11-30 22:20:01 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2019-03-21 22:28:12 +0000
commit3bf47e100717f4295652d578ecd12e489937b329 (patch)
tree38f6043ffc4dada7ef0e51126906375c24a03386 /goo
parent5610fc71fcd6b4c54e805470259ed95547aa2328 (diff)
Make GooList a template type
One more step towards getting rid of it completely.
Diffstat (limited to 'goo')
-rw-r--r--goo/GooList.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/goo/GooList.h b/goo/GooList.h
index 78685fea..172d0d71 100644
--- a/goo/GooList.h
+++ b/goo/GooList.h
@@ -31,7 +31,8 @@
// GooList
//------------------------------------------------------------------------
-class GooList : public std::vector<void *> {
+template <typename T>
+class GooList : public std::vector<T> {
public:
// Create an empty list.
@@ -45,18 +46,18 @@ public:
GooList& operator=(const GooList &other) = delete;
// Zero cost conversion from std::vector
- explicit GooList(const std::vector<void *>& vec) : std::vector<void *>(vec) {}
- explicit GooList(std::vector<void *>&& vec) : std::vector<void *>(std::move(vec)) {}
+ explicit GooList(const std::vector<T>& vec) : std::vector<T>(vec) {}
+ explicit GooList(std::vector<T>&& vec) : std::vector<T>(std::move(vec)) {}
// Return the <i>th element.
// Assumes 0 <= i < length.
- void *get(int i) const { return (*this)[i]; }
+ const T& get(int i) const { return (*this)[i]; }
};
template<typename T>
-inline void deleteGooList(GooList* list) {
+inline void deleteGooList(GooList<T>* list) {
for (auto ptr : *list) {
- delete static_cast<T *>(ptr);
+ delete ptr;
}
delete list;
}