Boost C++ Libraries: Ticket #6216: Add an unwrap adaptor to Range https://svn.boost.org/trac10/ticket/6216 <p> Iterator adaptors can be easily unwrapped by calling <code>iterator .base ()</code>; range adaptors should provide a similar functionality. </p> <p> My implementation: </p> <div class="wiki-code"><div class="code"><pre><span class="k">namespace</span> <span class="n">boost</span> <span class="p">{</span> <span class="k">namespace</span> <span class="n">adaptors</span> <span class="p">{</span> <span class="k">namespace</span> <span class="n">detail</span> <span class="p">{</span> <span class="k">struct</span> <span class="n">unwrap_forwarder</span> <span class="p">{};</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_R</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">iterator_range</span> <span class="o">&lt;</span> <span class="k">typename</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">range_iterator</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="o">&gt;::</span> <span class="n">type</span><span class="o">::</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="k">operator</span> <span class="o">|</span> <span class="p">(</span><span class="n">P_R</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">,</span> <span class="n">detail</span><span class="o">::</span> <span class="n">unwrap_forwarder</span> <span class="k">const</span> <span class="o">&amp;</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">make_iterator_range</span> <span class="p">(</span><span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">begin</span> <span class="p">(</span><span class="n">p_r</span><span class="p">).</span> <span class="n">base</span> <span class="p">(),</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">end</span> <span class="p">(</span><span class="n">p_r</span><span class="p">).</span> <span class="n">base</span> <span class="p">());</span> <span class="p">}</span> <span class="cm">/* !boost.adaptors.|unwrapped X */</span> <span class="p">}</span> <span class="cm">/* &amp;boost.adaptors.detail X */</span> <span class="k">namespace</span> <span class="p">{</span> <span class="n">detail</span><span class="o">::</span> <span class="n">unwrap_forwarder</span> <span class="k">const</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">unwrapped</span><span class="p">)</span> <span class="p">((</span><span class="n">detail</span><span class="o">::</span> <span class="n">unwrap_forwarder</span> <span class="p">()));</span> <span class="p">}</span> <span class="p">}</span> <span class="cm">/* &amp;boost.adaptors X */</span> <span class="p">}</span> <span class="cm">/* &amp;boost X */</span> </pre></div></div><p> My test: </p> <div class="wiki-code"><div class="code"><pre><span class="kt">int</span> <span class="nf">main</span> <span class="p">()</span> <span class="p">{</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">iterator_range</span> <span class="o">&lt;</span> <span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">string</span><span class="o">::</span> <span class="n">const_iterator</span> <span class="o">&gt;</span> <span class="p">((</span><span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">equal_range</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">string</span> <span class="p">()</span> <span class="o">|</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">adaptors</span><span class="o">::</span> <span class="n">transformed</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">negate</span> <span class="o">&lt;</span> <span class="kt">int</span> <span class="o">&gt;</span> <span class="p">()),</span> <span class="mi">0</span><span class="p">)</span> <span class="o">|</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">adaptors</span><span class="o">::</span> <span class="n">unwrapped</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/6216 Trac 1.4.3