I would like to be able to do something like this:
// See output_xhtml.h
struct StartTag;
struct CompTag : public StartTag;
typedef std::deque<StartTag> TagDeque;
TagDeque td;
StartTag st;
CompTag ct;
td.push_back(st);
td.push_back(ct);
etc.
Unfortunately, this does not really work, because the container ONLY
holds StartTags and never holds CompTags. So the CompTag gets pushed,
but only as a StartTag.
Apparently, there are a few ways to handle this problem:
(i) Use a container of pointers, or of smart pointers.
(ii) Use the boost::ptr_container library:
http://www.boost.org/doc/libs/1_53_0/libs/ptr_container/doc/ptr_container.html
Anyone have a view on this?
Another option would be to give up on inheritance and fake it somehow,
e.g., using a boolean flag to tell me whether my StartTag is really a
CompTag.
Richard