Boost C++ Libraries: Ticket #4621: Feature Request: add some version of "type erasure" range/iterator https://svn.boost.org/trac10/ticket/4621 <p> Hi! </p> <blockquote> <p> I successfully use B.Lambda/B.Function for closure functionality in my code and would like to do the same with complex iterators/ranges . I've successfully implemented such "any" iterator range on top of any_iterator ( thanks to <a class="ext-link" href="http://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html"><span class="icon">​</span>http://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html</a> ), see <a class="ext-link" href="http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mlib/range/any_range.h"><span class="icon">​</span>any_range.h</a> . The common use case is as follows (my real code, <a class="ext-link" href="http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mgui/editor/select.cpp"><span class="icon">​</span>select.cpp</a>): </p> </blockquote> <div class="wiki-code"><div class="code"><pre> <span class="n">fe</span><span class="o">::</span><span class="n">range</span><span class="o">&lt;</span><span class="n">Comp</span><span class="o">::</span><span class="n">MediaObj</span><span class="o">*&gt;</span> <span class="n">SelectedMediaObjs</span><span class="p">(</span><span class="n">MenuRegion</span><span class="o">&amp;</span> <span class="n">mn_rgn</span><span class="p">,</span> <span class="k">const</span> <span class="n">int_array</span><span class="o">&amp;</span> <span class="n">sel_arr</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">fe</span><span class="o">::</span><span class="n">make_any</span><span class="p">(</span> <span class="n">sel_arr</span> <span class="o">|</span> <span class="n">fe</span><span class="o">::</span><span class="n">transformed</span><span class="p">(</span><span class="n">ToMOTransform</span><span class="p">(</span><span class="n">mn_rgn</span><span class="p">))</span> <span class="p">);</span> <span class="p">}</span> <span class="n">fe</span><span class="o">::</span><span class="n">range</span><span class="o">&lt;</span><span class="n">Comp</span><span class="o">::</span><span class="n">MediaObj</span><span class="o">*&gt;</span> <span class="n">SelectedMediaObjs</span><span class="p">(</span><span class="n">MEditorArea</span><span class="o">&amp;</span> <span class="n">edt_area</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">SelectedMediaObjs</span><span class="p">(</span><span class="n">edt_area</span><span class="p">.</span><span class="n">CurMenuRegion</span><span class="p">(),</span> <span class="n">edt_area</span><span class="p">.</span><span class="n">SelArr</span><span class="p">());</span> <span class="p">}</span> <span class="p">...</span> <span class="c1">// somewhere else</span> <span class="p">...</span> <span class="n">BOOST_FOREACH</span><span class="p">(</span> <span class="n">Comp</span><span class="o">::</span><span class="n">MediaObj</span><span class="o">*</span> <span class="n">obj</span><span class="p">,</span> <span class="n">SelectedMediaObjs</span><span class="p">(</span><span class="n">edt_area</span><span class="p">)</span> <span class="p">)</span> <span class="p">{</span> <span class="n">res_mi</span> <span class="o">=</span> <span class="n">obj</span><span class="o">-&gt;</span><span class="n">MediaItem</span><span class="p">();</span> <span class="k">break</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4621 Trac 1.4.3 Ilya Murav'jov <muravev@…> Thu, 02 Sep 2010 12:00:45 GMT attachment set https://svn.boost.org/trac10/ticket/4621 https://svn.boost.org/trac10/ticket/4621 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">any_range.h</span> </li> </ul> Ticket Neil Groves Mon, 03 Jan 2011 19:06:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4621#comment:1 https://svn.boost.org/trac10/ticket/4621#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Implementation added to the trunk. </p> Ticket