Boost C++ Libraries: Ticket #695: permutation_iterator does not support conversions https://svn.boost.org/trac10/ticket/695 <pre class="wiki">The current implementation of boost::permutation_iterator does not support compatible conversions. The below attached example demonstrates the problem. The reason is due to the fact that the converting c'tor template&lt;class OtherElementIterator, class OtherIndexIterator&gt; permutation_iterator( permutation_iterator&lt;OtherElementIterator, OtherIndexIterator&gt; const&amp; r , typename enable_if_convertible&lt;OtherElementIterator, ElementIterator&gt;::type* = 0 , typename enable_if_convertible&lt;OtherIndexIterator, IndexIterator&gt;::type* = 0 ) : super_t(r.base()), m_elt_iter(r.m_elt_iter) {} is provoked in the example and is generally defective: There exists no public accessor for the private member m_elt_iter and thus it's access is not allowed at the point of its copy construction. There exists two solutions to fix this issue. Since I'm not sure, which is the best one, I propose both: Solution (1): Add template &lt;typename, typename&gt; friend class permutation_iterator; inside the permutation_iterator class template. Advantage: Does not change the current interface of permutation_iterator&lt;&gt;, disadvantage: It provides friendship to every template permutation_iterator&lt;typename&gt;, which could theoretically be hijacked be programmers, which define their own template specialization of the c'tor (See http://www.gotw.ca/gotw/076.htm "The Language Lawyer"), although that risk is low. Solution (2): Provide a public accessor for member m_elt_iter, e.g. ElementIterator element_iterator() const { return m_elt_iter; } and call this member function in the conversion c'tor instead of direct member access. The advantage is that no friendship is needed (;-)), the disadvantage is, that it adds a new public member. I actual problem with that accessor for the internal element iterator is: What expect users, which position it corresponds to? Is it its current position or is it its initial position (which is true, of course). The last argument could be weakened by enforcing a more descriptive name, e.g. primary_element_iterator(). I will provide cvs patches in the following minutes </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/695 Trac 1.4.3 daniel_kruegler Sat, 29 Jul 2006 19:40:53 GMT <link>https://svn.boost.org/trac10/ticket/695#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/695#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=1540640 cvs patch for solution (1) Index: permutation_iterator.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/iterator/permutation_iterator.hpp,v retrieving revision 1.4 diff -r1.4 permutation_iterator.hpp 33a34,35 &gt; template &lt;typename, typename&gt; friend class permutation_iterator; &gt; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>daniel_kruegler</dc:creator> <pubDate>Sat, 29 Jul 2006 19:42:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/695#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/695#comment:2</guid> <description> <pre class="wiki">Logged In: YES user_id=1540640 cvs patch for solution (2) Index: permutation_iterator.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/iterator/permutation_iterator.hpp,v retrieving revision 1.4 diff -r1.4 permutation_iterator.hpp 46c46 &lt; : super_t(r.base()), m_elt_iter(r.m_elt_iter) --- &gt; : super_t(r.base()), m_elt_iter(r.element_iterator()) 47a48,49 &gt; &gt; ElementIterator element_iterator() const { return m_elt_iter; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>david_abrahams</dc:creator> <pubDate>Wed, 13 Sep 2006 22:37:03 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/695#comment:3 https://svn.boost.org/trac10/ticket/695#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket