Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-02-25 10:19:57


When inheriting from an STL container the constructors and local typedefs
need to be redeclared. For instance the vector contract class at
http://www.ootl.org/pwc/pwc_vector.hpp.htm .

It seems to me that it would be very useful to have a single macro for each
of the different STL containers to ease inheritance of them. Does Boost
already have something like that? If not would anyone else want something
like this for Boost? Or am I really missing something basic here, and this
is a bad idea for some obscure C++ reason?

i.e.

#define BOOST_STL_VECTOR_OVERRIDE(NAME, ELEMENT) /* */ \
    typedef std::vector<ELEMENT> inherited; \
    typedef typename inherited::size_type size_type; \
    typedef typename inherited::reference reference; \
    typedef typename inherited::iterator iterator; \
    typedef typename inherited::const_iterator const_iterator; \
    typedef typename inherited::reverse_iterator reverse_iterator; \
    typedef typename inherited::const_reverse_iterator
const_reverse_iterator; \
    NAME() { } \
    NAME(size_type n) : inherited(n) { } \
    NAME(size_type n, const ELEMENT& t) : inherited(n, t) { } \
    NAME(const NAME& x) : inherited(x) { } \
    NAME(const inherited& x) : inherited(x) { } \
    template <class InputIterator> \
    NAME(InputIterator x0, InputIterator x1) : inherited(x0, x1) { } \
    /* */

Christopher Diggins
Object Oriented Template Library (OOTL)
http://www.ootl.org


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk