Boost C++ Libraries: Ticket #9072: `iterator_range` does not accept iterators having "reference to function type" as `reference` nested type https://svn.boost.org/trac10/ticket/9072 <p> This is a very minor thing. </p> <p> This code works: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/iterator/transform_iterator.hpp&gt; void zero() { std::cout &lt;&lt; "zero" &lt;&lt; std::endl; } void non_zero() { std::cout &lt;&lt; "non-zero" &lt;&lt; std::endl; } typedef void function_type(); function_type&amp; f(int i) { if (i == 0) { return zero; } else { return non_zero; } } int main(int argc, char* argv[]) { int ar[2] = {0, 1}; typedef boost::transform_iterator&lt;function_type&amp;(*)(int), int*&gt; iterator; iterator it_0 = boost::make_transform_iterator(ar + 0, f); iterator it_1 = boost::make_transform_iterator(ar + 1, f); (*it_0)(); (*it_1)(); return 0; } </pre><p> But this code does not compile: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/iterator/transform_iterator.hpp&gt; #include &lt;boost/range/iterator_range.hpp&gt; void zero() { std::cout &lt;&lt; "zero" &lt;&lt; std::endl; } void non_zero() { std::cout &lt;&lt; "non-zero" &lt;&lt; std::endl; } typedef void function_type(); function_type&amp; f(int i) { if (i == 0) { return zero; } else { return non_zero; } } int main(int argc, char* argv[]) { int ar[2] = {0, 1}; typedef boost::transform_iterator&lt;function_type&amp;(*)(int), int*&gt; iterator; typedef boost::iterator_range&lt;iterator&gt; range; range rng( boost::make_transform_iterator(ar, f) , boost::make_transform_iterator(ar + 2, f) ); rng[0](); rng[1](); return 0; } </pre><p> This is because <code>iterator_range</code> does not accept iterators having "reference to function type" as <code>reference</code> nested type. </p> <p> Patch attached. Tested on gcc-4.7 and clang trunk. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9072 Trac 1.4.3 Michel Morin Sat, 31 Aug 2013 12:50:40 GMT attachment set https://svn.boost.org/trac10/ticket/9072 https://svn.boost.org/trac10/ticket/9072 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">allow_func_ref.patch</span> </li> </ul> Ticket Michel Morin Sat, 31 Aug 2013 12:51:44 GMT owner, component changed https://svn.boost.org/trac10/ticket/9072#comment:1 https://svn.boost.org/trac10/ticket/9072#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">jeffrey.hellrung</span> to <span class="trac-author">Neil Groves</span> </li> <li><strong>component</strong> <span class="trac-field-old">iterator</span> → <span class="trac-field-new">range</span> </li> </ul> Ticket Neil Groves Sun, 02 Mar 2014 23:09:52 GMT status changed https://svn.boost.org/trac10/ticket/9072#comment:2 https://svn.boost.org/trac10/ticket/9072#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Neil Groves Sat, 08 Mar 2014 21:55:23 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9072#comment:3 https://svn.boost.org/trac10/ticket/9072#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket