<div class="gmail_quote">On Tue, Jan 24, 2012 at 12:58 AM, Chris Lattner <span dir="ltr"><<a href="mailto:sabre@nondot.org">sabre@nondot.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: lattner<br>
Date: Tue Jan 24 02:58:57 2012<br>
New Revision: 148791<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=148791&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=148791&view=rev</a><br>
Log:<br>
add ::drop_back() and ::drop_front() methods, which are like pop_front/pop_back on a vector, but a) aren't destructive to "this", and b) can take a # elements to drop.<br></blockquote><div><br></div><div>FWIW, the string_ref proposal for standardization provides pop_front and pop_back with an N that is the number of elements to pop... Would it be worth following that lead, and just copying the string ref before calling them? I'm particularly interested in the use case for returning the adjusted string in case we should add these methods to the standards proposal.</div>
<div><br></div><div>We did propose a 'slice' method that might be more what you want, it works much like Python slicing, so you can do 's.slice(2, -2)' which would be equivalent to 's.drop_front(2).drop_back(2)' AFAICT... I don't recall exactly how the LLVM StringRef slice works.</div>
</div>