<div class="gmail_quote">On Wed, Jan 5, 2011 at 5:13 PM, Dave Abrahams <span dir="ltr"><<a href="mailto:dave@boostpro.com">dave@boostpro.com</a>></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> ><br> > I might be asking for the impossible here, but given the lovely adaptor<br> > syntax, eg<br> ><br> > std::vector<int> vec;<br> > boost::copy( vec | boost::adaptors::reversed<br> > � � � � � � � � �| boost::adaptors::uniqued,<br> > � � � � � � �std::ostream_iterator<int>(std::cout) );<br> ><br> ><br> > I notice it still uses the function call notation in the outermost<br> > operation( boost::copy() ),<br> > can it be written to eliminate function call syntax completely, say<br> > something like<br> ><br> > vec | boost::adaptors::reversed | boost::adaptors::uniqued |<br> > boost::adaptors::copy( std::ostream_iterator<int>(std::cout) );<br> ><br> > or even<br> ><br> > vec | boost::adaptors::reversed | boost::adaptors::uniqued |<br> > std::ostream_iterator<int>(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're asking for has a completely different nature: it'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 'pipeline' of transformations has to end with<br>'eager' 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'm not sure that it would be possible to implement it unambiguously tho'.<br><br>- Rob.<br> <br>