1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- #include <vector>
- #include <memory>
- //#include <Iterator.tlh>
- //-----------------------------------------------------------------------------
- // VectorOfPtr
- //-----------------------------------------------------------------------------
- template <typename T>
- class VectorOfPtr : public std::vector <std::unique_ptr <T>>
- {
- typedef std::vector <std::unique_ptr <T>> inherited;
- public:
- // using inherited::inherited;
- VectorOfPtr ()
- {
- }
- VectorOfPtr (VectorOfPtr && from) : inherited (std::move (from))
- {
- }
- VectorOfPtr (const VectorOfPtr & from) = delete;
- ~VectorOfPtr ()
- {
- __noop;
- }
- public:
- inline void Attach (T * value)
- {
- std::unique_ptr <T> ptr (value);
- push_back (std::move (ptr));
- }
- inline int GetSize () const
- {
- return (int)size ();
- }
- inline bool IsEmpty () const
- {
- return inherited::empty ();
- }
- inline void Reset ()
- {
- clear ();
- }
- inline std::vector <T *> ToVector ()
- {
- std::vector <T *> to;
- for (const auto & Item : *this)
- {
- to.push_back (Item.get ());
- }
- return to;
- }
- // int IndexOf (const T * t) const;
- };
|