[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost
Subject:    Re: [boost] type of iterator_facade::value_type
From:       Steven Watanabe <watanabesj () gmail ! com>
Date:       2009-12-23 17:02:11
Message-ID: 4B324D13.3090108 () providere-consulting ! com
[Download RAW message or body]

AMDG

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
> 	  >::type
> 	>::type,
>   

Yes.  Although this is insufficient because it doesn't handle
proxies or rvalues.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic