Topic: HELP: list<_T>::iterator as member of _T
Author: "Bill Wade" <bill.wade@stoner.com>
Date: 1999/12/02 Raw View
scarleton@bigfoot.com wrote in message <81ub5j$oof$1@nnrp1.deja.com>...
>How od I do this?
The standard way is to add a level of indirection. For instance make
list<T*>::iterator a member of T rather than list<T>.
Non-standard methods would cheat and make assumptions about the size and
alignment of list<T>::iterator.
For instance if you assume that list<X>::iterator has the same size and
alignment for all (X) it is easy to make T contain a list<int>::iterator (to
reserve sufficient aligned memory) which you always treat as a
list<T>::iterator (including special handling in 'structors). I've never
done that except as an academic exercise.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: scarleton@bigfoot.com
Date: 1999/11/30 Raw View
I am trying to put an iterator of a list into the object which makes up
the list:
class CItem;
typedef std::list<CItem> ItemArray;
class CItem : public CWindow
{
public:
CItem();
virtual ~CItem();
private:
ItemArray::iterator m_iaiParent; << compiler doesn't like this
};
How od I do this?
Sam Carleton
scarleton@bigfoot.com
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]