Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-04-29 10:44:52


It is clear to me that we must avoid inducing multiple inheritance for the
common uses of operators.hpp. Many common compilers will use the empty base
optimization for single inheritance, but as we've seen the problem is a bit
tougher when MI is involved. The only obvious solution, IMO, is to do
something which allows the following (which will cause a chain of single
inheritance):

template <class T,
        class V,
        class D = std::iterator_traits<char*>::difference_type,
        class P = V*,
        class R = V&>
struct bidirectional_iterator_helper :
equality_comparable<T,
  incrementable<T,
    decrementable<T,
      dereferenceable<T,V,
        std::iterator<std::bidirectional_iterator_tag, V, D>
>
>
>
>
{ };

I think one upshot of this technique, though, is that the use of partial
specialization for 2-type versions of some operator templates, such as
equality_comparable, must finally die (or at least lose backward
compatibility) in favor of the versions with "2" at the end of the name. I
don't see any way around this. If you do, please speak up!

The reason is that the common, single-argument usage needs to be augmented
with a 2nd type argument which allows the base-class chaining shown above
(and defaults to some empty class). Thus, we can no longer use it for the
optional 2nd type for binary operations.

-Dave



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