I tried it out, yes you can get make_iterator_range with next to work.  I like boost::next but for what I wanted it does not seem to work appropriately.  Your example of &quot;make_iterator_range(boost::next(b.begin, wSize), v.end())&quot; will only skip the first &quot;wSize&quot; elements.  What I want is a range that contains at most wSize elements (if possible) - taking them from after (and containing) a start index.  <div>
<br></div><div>Even my second attempt with this approach (commented out lines) does not work because next does not check to see if it is past end.  Perhaps if there is a &quot;min&quot; method I could pass the &quot;boost::next(v.begin() + (start-1), window)&quot; and &quot;v.end()&quot;.<br>
<div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">	</span>typedef vector&lt;int&gt; Vector;</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>Vector v = { 1, 2, 3, 4, 5, 6, 7, 8 , 9, 10, 11 };</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span>cout &lt;&lt; &quot;--&quot; &lt;&lt; endl;</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>for(auto i : v) { cout &lt;&lt; i &lt;&lt; &quot; &quot;; }</div>
<div><span class="Apple-tab-span" style="white-space:pre">	</span>cout &lt;&lt; &quot;\n--\n&quot; &lt;&lt; endl;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span>const int start = 10;</div>
<div><span class="Apple-tab-span" style="white-space:pre">	</span>const int window = 4;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span>auto r = boost::make_iterator_range(boost::next(v.begin(), start-1), v.end());</div>
<div><span class="Apple-tab-span" style="white-space:pre">	</span>auto r2 = boost::make_iterator_range(boost::prior(r.end(), window), r.end());</div><div><br></div><div><div>//<span class="Apple-tab-span" style="white-space:pre">	</span>auto r = boost::make_iterator_range(v.begin() + (start-1), boost::next(v.begin() + (start-1), window) );</div>
<div>//<span class="Apple-tab-span" style="white-space:pre">	</span>auto r2 = boost::make_iterator_range(boost::prior(r.end(), window), r.end());</div></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span>cout &lt;&lt; &quot;\n--\nr: &quot;;</div>
<div><span class="Apple-tab-span" style="white-space:pre">	</span>for(auto i : r) { cout &lt;&lt; i &lt;&lt; &quot; &quot;; }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span>cout &lt;&lt; &quot;\n--\nr2: &quot;;</div>
<div><span class="Apple-tab-span" style="white-space:pre">	</span>for(auto i : r2) { cout &lt;&lt; i &lt;&lt; &quot; &quot;; }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span>cout &lt;&lt; &quot;\n--\n&quot; &lt;&lt; endl;</div>
<br><div class="gmail_quote">On Tue, Oct 30, 2012 at 1:18 AM, Neil Groves-3 [via Boost] <span dir="ltr">&lt;<a href="/user/SendEmail.jtp?type=node&node=4637789&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>&gt;</span> wrote:<br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

	<br><div class="gmail_quote"><div class="im">On Tue, Oct 30, 2012 at 3:08 AM, David Kimmel <span dir="ltr">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=4637772&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span> wrote:<br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote">
Whoa fast responses!<div><br></div><div>I like make_iterator_range and sliced but they don&#39;t quite seem to do it.  Good point on the std::distance.  No need to add a new make_iterator_range - I may consider rethinking my approach or just leaving as is.  Thanks everyone!<div>

<div><br></div></div></div></blockquote><div><br></div><div><br></div></div><div class="im"><div>make_iterator_range is perfectly capable of meeting your expressed requirements. I have done this many times, I&#39;m not hypothesising. Please see my original post. You just use boost::next to advance one of the iterators that define the range.</div>

<div><br></div><div>See <a href="http://www.boost.org/doc/libs/1_51_0/libs/utility/utility.htm" rel="nofollow" link="external" target="_blank">http://www.boost.org/doc/libs/1_51_0/libs/utility/utility.htm</a></div><div><br>
</div><div>While respecting Thorsten&#39;s opinion and the wish to provide convenience functions to our users, I&#39;m not keen on introducing make_iterator_range (iterator, size_type) it seems like an unnecessary addition that would not significantly improve syntax. It would also duplicate the logic behind boost::next within non-member functions in Boost.Range like make_iterator_range. I prefer orthogonal solutions and composition to duplication of the advance logic.</div>

<div> </div><div>Neil Groves</div></div></div>
<br><div class="im">_______________________________________________
<br>Boost-users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&amp;node=4637772&amp;i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" rel="nofollow" link="external" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a>

	
	
	
	<br>
	<br>
	<hr noshade size="1" color="#cccccc">
	</div><div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif"><div class="im">
		<div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
		</div><a href="http://boost.2283326.n4.nabble.com/Iterator-Range-sub-range-of-a-desired-size-tp4637719p4637772.html" target="_blank" rel="nofollow" link="external">http://boost.2283326.n4.nabble.com/Iterator-Range-sub-range-of-a-desired-size-tp4637719p4637772.html</a>
	</div><div class="HOEnZb"><div class="h5">
	<div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
		
		To unsubscribe from Iterator Range, sub range of a desired size, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>

		<a href="http://boost.2283326.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&amp;id=instant_html%21nabble%3Aemail.naml&amp;base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&amp;breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
	</div></div></div></blockquote></div><br></div></div>


	
	
	
<br/><hr align="left" width="300" />
View this message in context: <a href="http://boost.2283326.n4.nabble.com/Iterator-Range-sub-range-of-a-desired-size-tp4637719p4637789.html">Re: Iterator Range, sub range of a desired size</a><br/>
Sent from the <a href="http://boost.2283326.n4.nabble.com/Boost-Users-f2553780.html">Boost - Users mailing list archive</a> at Nabble.com.<br/>