Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-14 01:03:59


----- Original Message -----
From: "rogeeff" <rogeeff_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, December 14, 2001 12:46 AM
Subject: [boost] iterator_adaptor and statefull policies.

> Hi,
>
> I have a question about iterator_adaptor. The iterator_adaptor seems
> to assume that Policies are stateless. For example, it never copy
> them in copy constructor and iterator.

You must be looking at different code than I am. The version I have on my
disk seems to copy policies (BTW, there is no user-defined copy-constructor,
so the default one takes effect).

> Why it was designed that way?

It wasn't! ;-)

> Another related questions:
> Why does not iterator_adapter has a copy_constructor/assignment
> accepting Base iterator?

A copy constructor always takes the same type as *this, so the first is
impossible. I guess we didn't add the assignment operator because implicit
conversions are the root of all evil ;-)

> Why does not iterator_adapter has a constructor accepting some
> argument to be passed to policy constructor?

How many arguments should be passed? Rather than account for all possible
combinations, you pass a policies object to the constructor.

> If there are reasons for such design, how to implement what I need?
>
> Another separate issue:
> If my Base input iterator returns reference as result of operator*,
> how to prevent iterator_adaptor::operator-> to create a proxy?

Just make sure it's at least a ForwardIterator. Only InputIterators create a
proxy.

Regards,
Dave


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