Subject: Re: [boost] type of iterator_facade::value_type
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-12-23 12:02:11
Neal Becker wrote:
> According to iterator_facade doc:
> typedef remove_const<Value>::type value_type;
> Why remove_const?
This is what the standard does.
> This makes it hard to detect if the resulting iterator
> points to a const value.
value_type is intended to give a type that can be used for temporaries, etc.
It was not designed as a general purpose type deduction mechanism.
For this purpose, reference is better because reference gives the
exact type from dereferencing the iterator.
> In order to further adapt such an iterator, I needed to use the
> reference type instead of the value type to detect constness:
> typename boost::is_const<
> typename boost::remove_reference<
> typename std::iterator_traits<BaseIterator>::reference
Yes. Although this is insufficient because it doesn't handle
proxies or rvalues.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk