B
Bit Byte
I was thinking of writing a generic container (i.e. collection) class in
C++. It would have iterators etc to allow traversing and acessing the
dat items.
The only problem arose when I tried to implement it, as I realised that
most of the STL containers actually required a type at compile time. Any
ideas on how to proceed with this? (or am I re-inveting the wheel here?)
Snippet of class:
template <class T>
class Collection
{
<snip>
</snip>
private:
vector<T> m_items ; //just an illustration, wont work. I know
};
I don't want to use template specialization because then the class is
not generic enough. Also, I would like to be able to store pointers in
such a collection, using value semantics, if possible - anyone knows how
to do this ?
C++. It would have iterators etc to allow traversing and acessing the
dat items.
The only problem arose when I tried to implement it, as I realised that
most of the STL containers actually required a type at compile time. Any
ideas on how to proceed with this? (or am I re-inveting the wheel here?)
Snippet of class:
template <class T>
class Collection
{
<snip>
</snip>
private:
vector<T> m_items ; //just an illustration, wont work. I know
};
I don't want to use template specialization because then the class is
not generic enough. Also, I would like to be able to store pointers in
such a collection, using value semantics, if possible - anyone knows how
to do this ?