<div class="gmail_quote">On Wed, Jan 5, 2011 at 5:13 PM, Dave Abrahams <span dir="ltr">&lt;<a href="mailto:dave@boostpro.com">dave@boostpro.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
At Wed, 5 Jan 2011 16:05:56 +0000,<br>
<div><div></div><div class="h5">Robert Jones wrote:<br>
&gt;<br>
&gt; I might be asking for the impossible here, but given the lovely adaptor<br>
&gt; syntax, eg<br>
&gt;<br>
&gt; std::vector&lt;int&gt; vec;<br>
&gt; boost::copy( vec | boost::adaptors::reversed<br>
&gt; � � � � � � � � �| boost::adaptors::uniqued,<br>
&gt; � � � � � � �std::ostream_iterator&lt;int&gt;(std::cout) );<br>
&gt;<br>
&gt;<br>
&gt; I notice it still uses the function call notation in the outermost<br>
&gt; operation( boost::copy() ),<br>
&gt; can it be written to eliminate function call syntax completely, say<br>
&gt; something like<br>
&gt;<br>
&gt; vec | boost::adaptors::reversed | boost::adaptors::uniqued |<br>
&gt; boost::adaptors::copy( std::ostream_iterator&lt;int&gt;(std::cout) );<br>
&gt;<br>
&gt; or even<br>
&gt;<br>
&gt; vec | boost::adaptors::reversed | boost::adaptors::uniqued |<br>
&gt; std::ostream_iterator&lt;int&gt;(std::cout);<br>
<br>
</div></div>It could be done, but it might not make much sense. �The boost<br>
adaptors are essentially lazy sequence transformations, but the copy<br>
operation you&#39;re asking for has a completely different nature: it&#39;s<br>
eager. �If you still like that syntax, though, you could write a<br>
suitable copy function of your own in about 40 lines that would do the<br>
same job.<br>
</blockquote></div><br>Yes.... I take your point about eager vs lazy, but on reflection is it not<br>the case that almost any &#39;pipeline&#39; of transformations has to end with<br>&#39;eager&#39; consumption?<br><br>If I had<br>
<br><span style="font-family: courier new,monospace;">int f( int );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">boost::for_each( vec | boost::adaptors::reversed | boost::adaptors::uniqued, f );</span><br style="font-family: courier new,monospace;">
<br>and instead were able to write it as<br><br><span style="font-family: courier new,monospace;">vec | boost::adaptors::reversed | boost::adaptors::uniqued | f;</span><br style="font-family: courier new,monospace;"><br>the final use of <span style="font-family: courier new,monospace;">operator|()</span> seems to pretty much imply eagerness in the<br>
same way that the <span style="font-family: courier new,monospace;">for_each()</span> does.<br><br>I&#39;m not sure that it would be possible to implement it unambiguously tho&#39;.<br><br>- Rob.<br>
<br>