Boost C++ Libraries: Ticket #6250: allow sorting through an adaptor https://svn.boost.org/trac10/ticket/6250 <p> The following code does not compile because the transform adaptor offers a proxy reference that cannot be modified: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/array.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/algorithm/copy.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/adaptor/transformed.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/bind.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/algorithm/sort.hpp&gt;</span><span class="cp"></span> <span class="k">struct</span> <span class="n">underlying</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">m_</span><span class="p">;</span> <span class="p">};</span> <span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="p">[])</span> <span class="p">{</span> <span class="k">enum</span> <span class="n">LocalParam</span> <span class="p">{</span> <span class="n">BASE</span> <span class="o">=</span> <span class="mo">073</span><span class="p">,</span> <span class="n">VALUE</span> <span class="o">=</span> <span class="mo">030</span> <span class="p">};</span> <span class="k">typedef</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">array</span> <span class="o">&lt;</span> <span class="n">underlying</span><span class="p">,</span> <span class="o">+</span><span class="n">BASE</span> <span class="o">-</span> <span class="mo">01</span> <span class="o">&gt;</span> <span class="n">mycont</span><span class="p">;</span> <span class="n">mycont</span> <span class="n">v</span><span class="p">;</span> <span class="k">for</span> <span class="p">(</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">mycont</span> <span class="o">&gt;::</span> <span class="n">type</span> <span class="n">p</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">v</span><span class="p">)));</span> <span class="n">p</span> <span class="o">&lt;</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">v</span><span class="p">);</span> <span class="o">++</span><span class="n">p</span><span class="p">)</span> <span class="n">p</span> <span class="o">-&gt;</span> <span class="n">m_</span> <span class="o">=</span> <span class="n">p</span> <span class="o">==</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">v</span><span class="p">)</span><span class="o">?</span> <span class="o">+</span><span class="nl">VALUE</span><span class="p">:</span> <span class="n">p</span> <span class="p">[</span><span class="o">-</span><span class="mo">01</span><span class="p">]</span> <span class="p">.</span><span class="n">m_</span> <span class="o">*</span> <span class="n">VALUE</span> <span class="o">%</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">copy</span> <span class="p">(</span><span class="n">v</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">boost</span> <span class="o">::</span><span class="n">bind</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">underlying</span> <span class="o">::</span><span class="n">m_</span><span class="p">,</span> <span class="n">_1</span><span class="p">)),</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">ostream_iterator</span> <span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">istream</span> <span class="o">::</span><span class="n">char_type</span> <span class="o">&gt;</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">cout</span><span class="p">,</span> <span class="s">&quot; &quot;</span><span class="p">));</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="sc">&#39;\n&#39;</span><span class="p">;</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">sort</span> <span class="p">(</span><span class="n">v</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">boost</span> <span class="o">::</span><span class="n">bind</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">underlying</span> <span class="o">::</span><span class="n">m_</span><span class="p">,</span> <span class="n">_1</span><span class="p">)));</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">copy</span> <span class="p">(</span><span class="n">v</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">boost</span> <span class="o">::</span><span class="n">bind</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">underlying</span> <span class="o">::</span><span class="n">m_</span><span class="p">,</span> <span class="n">_1</span><span class="p">)),</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">ostream_iterator</span> <span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">istream</span> <span class="o">::</span><span class="n">char_type</span> <span class="o">&gt;</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">cout</span><span class="p">,</span> <span class="s">&quot; &quot;</span><span class="p">));</span> <span class="k">return</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="sc">&#39;\n&#39;</span><span class="p">)</span> <span class="p">.</span><span class="n">flush</span> <span class="p">()</span><span class="o">?</span> <span class="o">+</span><span class="nl">EXIT_SUCCESS</span><span class="p">:</span> <span class="o">+</span><span class="n">EXIT_FAILURE</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> This is a deficiency because, when you have relational data packaged in a container, you often wish to create various indices based on various aspects of the data. This is currently unsupported by Boost, except for Multi-Index, but Multi-Index does not allow you to create a detached index; instead, it insists on maintaining all indices dynamically all the time, which is not always necessary and it brings a performance penalty compared to sorting static data. </p> <p> I have implemented the missing adaptor and called it <strong>shufflebase</strong>; when applied to an adaptor, it allows the sort algorithm to rearrange the <em>original container</em> based on <em>the ordering of the adaptor</em>. </p> <p> Here is the adaptor code; note that it does not carry any algorithm, only type juggling and general logistics: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/range/iterator_range.hpp&gt; /* boost:: iterator_range */</span><span class="cp"></span> <span class="cp">#ifndef BOOST_RANGE_ADAPTOR_SHUFFLEBASE_DEFINED</span> <span class="cp">#if 1</span> <span class="k">namespace</span> <span class="n">boost</span> <span class="p">{</span> <span class="cm">/*</span> <span class="cm">the following declarations are used in namespace adaptors;</span> <span class="cm">they are here to keep the namespace in one piece */</span> <span class="cp">#if 2</span> <span class="k">namespace</span> <span class="n">traits</span> <span class="p">{</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="k">struct</span> <span class="n">shufflebase</span><span class="p">;</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.traits */</span><span class="cp"></span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="k">class</span> <span class="nc">shufflebase_iterator</span><span class="p">;</span> <span class="cp">#if 2</span> <span class="k">namespace</span> <span class="n">adaptors</span> <span class="p">{</span> <span class="cm">/* a forward declaration for operator | */</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="k">struct</span> <span class="n">shufflebase_range</span><span class="p">;</span> <span class="cp">#if 3</span> <span class="k">namespace</span> <span class="n">detail</span> <span class="p">{</span> <span class="k">struct</span> <span class="cm">/* tag enabler for operator | */</span> <span class="n">shufflebase_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="k">struct</span> <span class="n">shufflebase_range</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="k">const</span> <span class="o">&gt;</span> <span class="cm">/* applies the shufflebase adaptor to a range */</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="k">struct</span> <span class="n">detail</span><span class="o">::</span> <span class="n">shufflebase_forwarder</span> <span class="p">);</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors.detail */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">namespace</span> <span class="cm">/* static */</span> <span class="p">{</span> <span class="n">detail</span> <span class="o">::</span> <span class="n">shufflebase_forwarder</span> <span class="k">const</span> <span class="cm">/* the formal parameter for operator | */</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">shufflebase</span><span class="p">)</span> <span class="p">((</span><span class="n">detail</span> <span class="o">::</span><span class="n">shufflebase_forwarder</span> <span class="p">()));</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors.static */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">namespace</span> <span class="n">traits</span> <span class="p">{</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_T</span> <span class="o">&gt;</span> <span class="k">struct</span> <span class="n">shufflebase_range</span><span class="p">;</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors.traits &amp; */</span><span class="cp"></span> <span class="cp">#if 3</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="cm">/* applies shufflebase_iterator to the range */</span> <span class="k">struct</span> <span class="nl">shufflebase_range</span> <span class="p">:</span><span class="k">public</span> <span class="n">traits</span> <span class="o">::</span><span class="n">shufflebase_range</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">base</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="kr">inline</span> <span class="n">shufflebase_range</span> <span class="p">(</span><span class="n">P_R</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">);</span> <span class="k">private</span><span class="o">:</span> <span class="k">typedef</span> <span class="n">traits</span> <span class="o">::</span><span class="n">shufflebase_range</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="o">&gt;</span> <span class="n">traits</span><span class="p">;</span> <span class="k">private</span><span class="o">:</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">traits</span> <span class="o">::</span><span class="n">base</span> <span class="n">base</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">traits</span> <span class="o">::</span><span class="n">iterator</span> <span class="n">iterator</span><span class="p">;</span> <span class="p">};</span> <span class="cp">#endif </span><span class="cm">/* #boost.adaptors.shufflebase_range */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">namespace</span> <span class="n">traits</span> <span class="p">{</span> <span class="cp">#if 4</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="cm">/* typedefs for shufflebase_range proper */</span> <span class="k">struct</span> <span class="n">shufflebase_range</span> <span class="p">{</span> <span class="k">typedef</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span> <span class="n">shufflebase_iterator</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="o">::</span><span class="n">type</span> <span class="o">&gt;</span> <span class="n">iterator</span><span class="p">;</span> <span class="k">typedef</span> <span class="k">struct</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="n">iterator</span> <span class="o">&gt;</span> <span class="n">base</span><span class="p">;</span> <span class="p">};</span> <span class="cp">#endif </span><span class="cm">/* #boost.adaptors.traits.shufflebase_range */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors.traits */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="cm">/*</span> <span class="cm">Behaves transparently when applied to an adapted iterator</span> <span class="cm">except that assignments are possible and apply to the underlying base */</span> <span class="k">class</span> <span class="nc">shufflebase_iterator</span> <span class="o">:</span><span class="k">public</span> <span class="cm">/* iterator faciade */</span> <span class="n">traits</span><span class="o">::</span> <span class="n">shufflebase</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;::</span> <span class="n">base_type</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* constructs from an adapted iterator */</span> <span class="kr">inline</span> <span class="n">shufflebase_iterator</span> <span class="p">(</span><span class="n">P_I</span> <span class="k">const</span> <span class="o">&amp;</span><span class="p">);</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* inherited */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">shufflebase_iterator</span> <span class="o">::</span><span class="n">reference</span> <span class="n">reference</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* returns a proxy reference */</span> <span class="kr">inline</span> <span class="n">reference</span> <span class="cm">/* safety net: exclude application of default operator = to temporary */</span> <span class="k">const</span> <span class="k">operator</span><span class="o">*</span> <span class="p">()</span> <span class="k">const</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* inherited */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">shufflebase_iterator</span> <span class="o">::</span><span class="n">value_type</span> <span class="n">value_type</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* assigns the value to the base element, bypassing the adaptor */</span> <span class="kr">inline</span> <span class="kt">void</span> <span class="n">assign</span> <span class="p">(</span><span class="n">value_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_v</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* bookkeeping */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">traits</span><span class="o">::</span> <span class="n">shufflebase</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;::</span> <span class="n">base_type</span> <span class="n">inherited</span><span class="p">;</span> <span class="p">};</span> <span class="cp">#endif </span><span class="cm">/* #boost.shufflebase_iterator */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">namespace</span> <span class="n">detail</span> <span class="p">{</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="k">class</span> <span class="nc">shufflebase_reference</span><span class="p">;</span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="cm">/*</span> <span class="cm">Stores a value of an iterator. </span> <span class="cm">This class plays a double duty:</span> <span class="cm">it stores the base value for assigning to a reference</span> <span class="cm">and it caches the adapted value for comparisons. </span> <span class="cm">This causes some memory overhead</span> <span class="cm">that I believe is unavoidable</span> <span class="cm">without knowing the details of the managed adaptor. </span> <span class="cm">Moreover, caching the adapted value may speed things up a bit. </span> <span class="cm">This class is necessary</span> <span class="cm">because the sorting algorithm puts some values aside for later use. */</span> <span class="k">class</span> <span class="nc">shufflebase_value</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* bookkeeping */</span> <span class="k">typedef</span> <span class="n">P_I</span> <span class="n">base_type</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* construct from a reference */</span> <span class="kr">inline</span> <span class="n">shufflebase_value</span> <span class="p">(</span><span class="k">class</span> <span class="nc">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">);</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* the adapted value type */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">iterator_traits</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">value_type</span> <span class="n">adapted</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* compares as adapted */</span> <span class="kr">inline</span> <span class="k">operator</span> <span class="n">adapted</span> <span class="k">const</span> <span class="o">&amp;</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span> <span class="k">private</span><span class="o">:</span> <span class="cm">/* the adapted value */</span> <span class="n">adapted</span> <span class="n">m_adapted</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* the base value type */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">traits</span> <span class="o">::</span><span class="n">shufflebase</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">base_value</span> <span class="n">base_value</span><span class="p">;</span> <span class="k">private</span><span class="o">:</span> <span class="cm">/* the base value */</span> <span class="n">base_value</span> <span class="n">m_base</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/*</span> <span class="cm">returns the base value for assignment</span> <span class="cm">(the adapter is meant to affect the base container, remember? */</span> <span class="kr">inline</span> <span class="n">base_value</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">base</span> <span class="p">()</span> <span class="k">const</span><span class="p">;</span> <span class="p">};</span> <span class="cp">#endif </span><span class="cm">/* #boost.detail.shufflebase_value */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="cm">/*</span> <span class="cm">A proxy class serving as reference type for shufflebase_iterator. </span> <span class="cm">Implicitly converts to the adapted reference for comparisons. </span> <span class="cm">Assignment affects the base object instead.</span> <span class="cm"> */</span> <span class="k">class</span> <span class="nc">shufflebase_reference</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* bookkeeping */</span> <span class="k">typedef</span> <span class="n">P_I</span> <span class="n">base_type</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* the adapted reference type */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">iterator_traits</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">reference</span> <span class="n">reference</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* compares as adapted */</span> <span class="kr">inline</span> <span class="k">operator</span> <span class="n">reference</span> <span class="k">const</span> <span class="p">()</span> <span class="k">const</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* the adapted value type */</span> <span class="k">typedef</span> <span class="k">class</span> <span class="nc">shufflebase_value</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="n">value_type</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* assigned value goes to base */</span> <span class="kr">inline</span> <span class="n">shufflebase_reference</span> <span class="k">const</span> <span class="o">&amp;</span><span class="k">operator</span><span class="o">=</span> <span class="p">(</span><span class="n">value_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_v</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* constructor */</span> <span class="kr">inline</span> <span class="n">shufflebase_reference</span> <span class="p">(</span><span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="p">);</span> <span class="k">private</span><span class="o">:</span> <span class="cm">/* the proxied iterator */</span> <span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">m_ref</span><span class="p">;</span> <span class="k">public</span><span class="o">:</span> <span class="cm">/* extract the base value for assigning to a value object */</span> <span class="kr">inline</span> <span class="k">typename</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">iterator_traits</span> <span class="o">&lt;</span> <span class="k">typename</span> <span class="n">base_type</span><span class="o">::</span> <span class="n">base_type</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">value_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">base</span> <span class="p">()</span> <span class="k">const</span><span class="p">;</span> <span class="k">private</span><span class="o">:</span> <span class="cm">/* references are not assignable */</span> <span class="kt">void</span> <span class="k">operator</span> <span class="o">=</span> <span class="p">(</span><span class="n">shufflebase_reference</span> <span class="k">const</span> <span class="o">&amp;</span><span class="p">);</span> <span class="p">};</span> <span class="cp">#endif </span><span class="cm">/* #boost.detail.shufflebase_reference */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.detail */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">namespace</span> <span class="n">traits</span> <span class="p">{</span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="cm">/* contains typedefs for shufflebase_iterator */</span> <span class="k">struct</span> <span class="n">shufflebase</span> <span class="p">{</span> <span class="cm">/* bookkeeping */</span> <span class="k">typedef</span> <span class="n">P_I</span> <span class="n">iterator</span><span class="p">;</span> <span class="cm">/* the base type for shufflebase_iterator */</span> <span class="k">typedef</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">iterator_adaptor</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">iterator</span> <span class="o">&gt;</span><span class="p">,</span> <span class="n">iterator</span><span class="p">,</span> <span class="k">class</span> <span class="nc">detail</span><span class="o">::</span> <span class="n">shufflebase_value</span> <span class="o">&lt;</span> <span class="n">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">use_default</span><span class="p">,</span> <span class="k">class</span> <span class="nc">detail</span><span class="o">::</span> <span class="n">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">iterator</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">base_type</span><span class="p">;</span> <span class="cm">/* the base value */</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">iterator_traits</span> <span class="o">&lt;</span> <span class="k">typename</span> <span class="n">iterator</span> <span class="o">::</span><span class="n">base_type</span> <span class="o">&gt;::</span> <span class="n">value_type</span> <span class="n">base_value</span><span class="p">;</span> <span class="cm">/*</span> <span class="cm">The proper place to define base_value would be class shufflebase_value;</span> <span class="cm">however, this type is shared by other auxiliary classes;</span> <span class="cm">they depend on each other, causing the compiler to fail. */</span> <span class="p">};</span> <span class="cp">#endif </span><span class="cm">/* #boost.traits.shufflebase */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.traits */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost */</span><span class="cp"></span> <span class="cp">#define BOOST_RANGE_ADAPTOR_SHUFFLEBASE_DEFINED</span> <span class="cp">#endif</span> <span class="cp">#ifndef BOOST_RANGE_ADAPTOR_SHUFFLEBASE_IMPLEMENTED</span> <span class="cp">#if 1</span> <span class="k">namespace</span> <span class="n">boost</span> <span class="p">{</span> <span class="cp">#if 2</span> <span class="k">namespace</span> <span class="n">adaptors</span> <span class="p">{</span> <span class="cp">#if 3</span> <span class="k">namespace</span> <span class="n">detail</span> <span class="p">{</span> <span class="cp">#if 4</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="k">struct</span> <span class="n">shufflebase_range</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="k">const</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">shufflebase_forwarder</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">shufflebase_range</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="k">const</span> <span class="o">&gt;</span> <span class="p">(</span><span class="n">p_r</span><span class="p">);</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.adaptors.shufflebase_range.operator| */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors.detail */</span><span class="cp"></span> <span class="cp">#if 3</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="n">shufflebase_range</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">shufflebase_range</span> <span class="p">(</span><span class="n">P_R</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">)</span> <span class="o">:</span><span class="n">base</span> <span class="p">(</span><span class="n">iterator</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">iterator</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="p">{}</span> <span class="cp">#endif </span><span class="cm">/* !boost.adaptors.shufflebase_range.shufflebase_range */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.adaptors */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="k">typename</span> <span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">reference</span> <span class="k">const</span> <span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="k">operator</span> <span class="o">*</span> <span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="o">*</span><span class="k">this</span><span class="p">;</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.shufflebase_iterator.operator * */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">namespace</span> <span class="n">detail</span> <span class="p">{</span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="n">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="k">operator</span> <span class="n">reference</span> <span class="k">const</span> <span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="o">*</span><span class="k">this</span> <span class="o">-&gt;</span> <span class="n">m_ref</span><span class="p">.</span> <span class="n">base</span> <span class="p">();</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_reference::reference */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="n">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="k">operator</span> <span class="o">=</span> <span class="p">(</span><span class="n">value_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_v</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">this</span> <span class="o">-&gt;</span> <span class="n">m_ref</span> <span class="p">.</span><span class="n">assign</span> <span class="p">(</span><span class="n">p_v</span><span class="p">);</span> <span class="k">return</span> <span class="o">*</span><span class="k">this</span><span class="p">;</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_reference::operator = */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="n">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">shufflebase_reference</span> <span class="p">(</span><span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_ref</span><span class="p">)</span> <span class="o">:</span><span class="n">m_ref</span> <span class="p">(</span><span class="n">p_ref</span><span class="p">)</span> <span class="p">{}</span> <span class="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_reference.shufflebase_reference */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="n">shufflebase_value</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">shufflebase_value</span> <span class="p">(</span><span class="k">class</span> <span class="nc">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">)</span> <span class="o">:</span><span class="n">m_adapted</span> <span class="p">(</span><span class="n">p_r</span><span class="p">),</span> <span class="n">m_base</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="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_value.shufflebase_value */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="n">shufflebase_value</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;::</span> <span class="k">operator</span> <span class="n">adapted</span> <span class="k">const</span> <span class="o">&amp;</span> <span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="k">this</span> <span class="o">-&gt;</span> <span class="n">m_adapted</span><span class="p">;</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_value.adapted &amp; */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="k">typename</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">iterator_traits</span> <span class="o">&lt;</span> <span class="k">typename</span> <span class="n">P_I</span> <span class="o">::</span><span class="n">base_type</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">value_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">shufflebase_reference</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span> <span class="n">base</span> <span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="o">*</span><span class="k">this</span> <span class="o">-&gt;</span> <span class="n">m_ref</span> <span class="p">.</span><span class="n">base</span> <span class="p">()</span> <span class="p">.</span><span class="n">base</span> <span class="p">();</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_reference.base */</span><span class="cp"></span> <span class="cp">#if 3</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="k">typename</span> <span class="n">shufflebase_value</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">base_value</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">shufflebase_value</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">base</span> <span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="k">this</span> <span class="o">-&gt;</span> <span class="n">m_base</span><span class="p">;</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.detail.shufflebase_value.base */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost.detail */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;::</span> <span class="n">shufflebase_iterator</span> <span class="p">(</span><span class="n">P_I</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_i</span><span class="p">)</span> <span class="o">:</span><span class="n">inherited</span> <span class="p">(</span><span class="n">p_i</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.shufflebase_iterator. */</span><span class="cp"></span> <span class="cp">#if 2</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_I</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="kt">void</span> <span class="n">shufflebase_iterator</span> <span class="o">&lt;</span> <span class="n">P_I</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">assign</span> <span class="p">(</span><span class="n">value_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_v</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="o">*</span><span class="k">this</span> <span class="o">-&gt;</span> <span class="n">base</span> <span class="p">().</span> <span class="n">base</span> <span class="p">()</span> <span class="o">=</span> <span class="n">p_v</span><span class="p">.</span> <span class="n">base</span> <span class="p">();</span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* !boost.shufflebase_iterator.assign */</span><span class="cp"></span> <span class="p">}</span> <span class="cp">#endif </span><span class="cm">/* &amp;boost */</span><span class="cp"></span> <span class="cp">#define BOOST_RANGE_ADAPTOR_SHUFFLEBASE_IMPLEMENTED</span> <span class="cp">#endif</span> </pre></div></div><p> Having this, the following code becomes valid: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/array.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/algorithm/copy.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/adaptor/transformed.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/bind.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/algorithm/sort.hpp&gt;</span><span class="cp"></span> <span class="k">struct</span> <span class="n">underlying</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">m_</span><span class="p">;</span> <span class="p">};</span> <span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="p">[])</span> <span class="p">{</span> <span class="k">enum</span> <span class="n">LocalParam</span> <span class="p">{</span> <span class="n">BASE</span> <span class="o">=</span> <span class="mo">073</span><span class="p">,</span> <span class="n">VALUE</span> <span class="o">=</span> <span class="mo">030</span> <span class="p">};</span> <span class="k">typedef</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">array</span> <span class="o">&lt;</span> <span class="n">underlying</span><span class="p">,</span> <span class="o">+</span><span class="n">BASE</span> <span class="o">-</span> <span class="mo">01</span> <span class="o">&gt;</span> <span class="n">mycont</span><span class="p">;</span> <span class="n">mycont</span> <span class="n">v</span><span class="p">;</span> <span class="k">for</span> <span class="p">(</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">mycont</span> <span class="o">&gt;::</span> <span class="n">type</span> <span class="n">p</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">v</span><span class="p">)));</span> <span class="n">p</span> <span class="o">&lt;</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">v</span><span class="p">);</span> <span class="o">++</span><span class="n">p</span><span class="p">)</span> <span class="n">p</span> <span class="o">-&gt;</span> <span class="n">m_</span> <span class="o">=</span> <span class="n">p</span> <span class="o">==</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">v</span><span class="p">)</span><span class="o">?</span> <span class="o">+</span><span class="nl">VALUE</span><span class="p">:</span> <span class="n">p</span> <span class="p">[</span><span class="o">-</span><span class="mo">01</span><span class="p">]</span> <span class="p">.</span><span class="n">m_</span> <span class="o">*</span> <span class="n">VALUE</span> <span class="o">%</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">copy</span> <span class="p">(</span><span class="n">v</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">boost</span> <span class="o">::</span><span class="n">bind</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">underlying</span> <span class="o">::</span><span class="n">m_</span><span class="p">,</span> <span class="n">_1</span><span class="p">)),</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">ostream_iterator</span> <span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">istream</span> <span class="o">::</span><span class="n">char_type</span> <span class="o">&gt;</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">cout</span><span class="p">,</span> <span class="s">&quot; &quot;</span><span class="p">));</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="sc">&#39;\n&#39;</span><span class="p">;</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">sort</span> <span class="p">(</span><span class="n">v</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">boost</span> <span class="o">::</span><span class="n">bind</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">underlying</span> <span class="o">::</span><span class="n">m_</span><span class="p">,</span> <span class="n">_1</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">shufflebase</span><span class="p">);</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">copy</span> <span class="p">(</span><span class="n">v</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">boost</span> <span class="o">::</span><span class="n">bind</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">underlying</span> <span class="o">::</span><span class="n">m_</span><span class="p">,</span> <span class="n">_1</span><span class="p">)),</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">ostream_iterator</span> <span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">istream</span> <span class="o">::</span><span class="n">char_type</span> <span class="o">&gt;</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">cout</span><span class="p">,</span> <span class="s">&quot; &quot;</span><span class="p">));</span> <span class="k">return</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="sc">&#39;\n&#39;</span><span class="p">)</span> <span class="p">.</span><span class="n">flush</span> <span class="p">()</span><span class="o">?</span> <span class="o">+</span><span class="nl">EXIT_SUCCESS</span><span class="p">:</span> <span class="o">+</span><span class="n">EXIT_FAILURE</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> and it produces the following output: </p> <p> 24 45 18 19 43 29 47 7 50 20 8 15 6 26 34 49 55 22 56 46 42 5 2 48 31 36 38 27 58 35 14 41 40 16 30 12 52 9 39 51 44 53 33 25 10 4 37 3 13 17 54 57 11 28 23 21 32 1 </p> <p> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6250 Trac 1.4.3 ne01026@… Mon, 19 Dec 2011 21:19:10 GMT attachment set https://svn.boost.org/trac10/ticket/6250 https://svn.boost.org/trac10/ticket/6250 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">make_index.cc</span> </li> </ul> <p> an implementation of make_index using shufflebase indexes an arbitrary transformed range </p> Ticket Dave Abrahams Wed, 21 Nov 2012 22:39:46 GMT owner changed https://svn.boost.org/trac10/ticket/6250#comment:1 https://svn.boost.org/trac10/ticket/6250#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Dave Abrahams</span> to <span class="trac-author">jeffrey.hellrung</span> </li> </ul> Ticket