[llvm-commits] [llvm] r148791 - /llvm/trunk/include/llvm/ADT/StringRef.h

Chandler Carruth chandlerc at google.com
Tue Jan 24 01:10:49 PST 2012


On Tue, Jan 24, 2012 at 12:58 AM, Chris Lattner <sabre at nondot.org> wrote:

> Author: lattner
> Date: Tue Jan 24 02:58:57 2012
> New Revision: 148791
>
> URL: http://llvm.org/viewvc/llvm-project?rev=148791&view=rev
> Log:
> 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.
>

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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120124/8b4c3853/attachment.html>


More information about the llvm-commits mailing list