Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-05-14 13:41:42


Hello shunsuke,

Monday, May 14, 2007, 5:05:46 PM, you wrote:

> Andrey Semashev wrote:
>> Currently is_const_iterator will result to true only if the iterator
>> reference type is const value or const reference. I'm not sure how it
>> should behave for iterators with a non-const value reference types and
>> vector< bool >::iterator specifically. I'm leaving this to users to
>> define by specializing is_const_iterator on their iterator types.
>> Maybe there should exist specialization on
>> vector< bool >::const_iterator right out of the box?

> I'm not sure, but this is an interesting question:
> Is it feasible to detect the writability of iterator using some language magic?
> If not, is_const_iterator can be a practical workarond.

The more I think of it the more I like the following solution:
- Make it fail to compile if dereferencing the iterator yelds a
non-reference type
- Provide specializations for vector< bool > iterators
- Add a note to the library docs about that

But I'd like to see what Dave thinks about it, as the library author.

> Well, I looked at the 'MyList' example.
> 'transform_iterator' could not be used?

Theoretically it could. But it seems to me a too heavy solution. The
iterator would contain a functor, which:
a) I don't need
b) either may be of unknown type (in case of bind or lambda
expressions) or is an additional class which I find very inconvenient.

To my mind, transform_iterator is handy when you want to provide a
view of the container to some algorithm from your (user's) code. It is
an overkill to use it as a part of a container implementation (library
code).

-- 
Best regards,
 Andrey                            mailto:andysem_at_[hidden]

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