|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-02-24 20:06:13
Christian Engström <christian.engstrom_at_[hidden]> writes:
> The reason why
> they are derived, in turn, is that we want the proxy iterators and the
> underlying "normal" iterators to be implicitly convertable to each
> other in both directions. If both conversions were user defined, as
> they would have to be if the proxy iterators could not utilize the
> implicit derived-to-base conversion, this would lead to a host of
> ambiguity problems, since the compiler has no reason to prefer one
> conversion over the other.
>
> The classic example is the expression a == b, which becomes ambiguous
> because the compiler is just as happy to carry out the comparison as
> either b_type(a) == b or a == a_type(b) if both conversions are
> available as implicit user defined conversions, and there is no ==
> operator defined for the mixed types case.
A classic example of a problem that can bve solved more elegantly by
the iterator adaptors library, *without* the problematic two-way
implicit conversion -- and it *is* problematic, even if one direction
is derived-to-base. You asked for feedback; I say look at the work
that those came before you already did in this area. I don't know why
you won't, but I've stopped trying now.
Cheers,
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk