Boost C++ Libraries: Ticket #1020: Boost.Iterator proposal to add is_constant_iterator https://svn.boost.org/trac10/ticket/1020 <p> I propose to add a new trait to the Boost.Iterator library: <code>is_constant_iterator</code>. The trait is applied to an iterator and returns true if the iterator's reference type is a constant reference and false if the type is a non-constant reference. The trait will fail to compile when applied to iterators having non-reference reference types. </p> <p> This addition would make it easier to use library components like <code>iterator_facade</code> and <code>iterator_adaptor</code> for implementing container iterator wrappers like this: </p> <pre class="wiki"> template&lt; NodeItT &gt; struct MyIterator : public iterator_facade&lt; MyIterator&lt; NodeItT &gt;, typename mpl::if_&lt; is_constant_iterator&lt; NodeItT &gt;, const value_type, value_type &gt;::type, typename iterator_category&lt; NodeItT &gt;::type &gt; { }; </pre><p> Here <code>NodeItT</code> is a wrapped iterator and may be a <code>const_iterator</code> or <code>iterator</code> of a container. </p> <p> Another use case is when a user wants to detect whether an iterator is <code>const_iterator</code> or <code>iterator</code>. An example of this: implementing functionality of iterator translation similar to Boost.<a class="missing wiki">MultiIndex</a> <code>project</code> method. </p> <p> I've attached an archive with the implementation, tests and patches to documentation. The implementation, in addition to the abovementioned functionality, supports <code>std::vector&lt; bool &gt;</code> iterators, though their reference types are not references. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1020 Trac 1.4.3 andysem@… Thu, 31 May 2007 18:50:44 GMT attachment set https://svn.boost.org/trac10/ticket/1020 https://svn.boost.org/trac10/ticket/1020 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">IsConstIterator.zip</span> </li> </ul> <p> Implementation, tests and documentation patches of the proposal </p> Ticket Joaquín M López Muñoz Wed, 11 Jul 2007 06:18:36 GMT owner set https://svn.boost.org/trac10/ticket/1020#comment:1 https://svn.boost.org/trac10/ticket/1020#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Dave Abrahams</span> </li> </ul> Ticket Dave Abrahams Thu, 26 Jun 2008 20:51:47 GMT owner changed https://svn.boost.org/trac10/ticket/1020#comment:2 https://svn.boost.org/trac10/ticket/1020#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Dave Abrahams</span> to <span class="trac-author">Thomas Witt</span> </li> </ul> <p> I can't make decisions about all iterator library tickets alone, and I'm unable to form a strong opinion about this one, so assigning to my coauthor Thomas Witt. </p> Ticket Dave Abrahams Wed, 21 Nov 2012 22:29:10 GMT owner changed https://svn.boost.org/trac10/ticket/1020#comment:3 https://svn.boost.org/trac10/ticket/1020#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Thomas Witt</span> to <span class="trac-author">jeffrey.hellrung</span> </li> </ul> Ticket