This is an archive of the discontinued LLVM Phabricator instance.

Implement p0457r2 - String Prefix and Suffix Checking
ClosedPublic

Authored by mclow.lists on Nov 28 2017, 3:32 PM.

Details

Summary

This adds six calls each to basic_string and basic_string_view:

  • starts_with (3 variants)
  • ends_with (3 variants)

This is a C++2a feature

Diff Detail

Event Timeline

mclow.lists created this revision.Nov 28 2017, 3:32 PM

Sorry for the extra bits.

include/string
1365

This is a leftover change. Disregard this bit.

test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
26

This one too.

51

This one three.

rsmith added a subscriber: rsmith.Nov 28 2017, 4:12 PM
rsmith added inline comments.
include/string
309

The indentation here seems off. Should these have a // C++2a comment?

1249

Indentation seems off here too.

include/string_view
151

I think we usually capitalize the C in these comments.

577

Is this a conforming implementation? The size() check isn't part of the specification, and compare could run arbitrary user-supplied code, so the absence of a call to it seems observable.

Don't get me wrong: I think this check is the right thing to do, and it only makes a difference if traits::compare has observable side-effects. But we should file a bug against the standard to get this check added there.

mclow.lists added inline comments.Nov 28 2017, 4:37 PM
include/string
309

I may have let a tab sneak in here. I'll be sure to de-tab before committing.

include/string_view
577

The code as specified in the paper has a bug in it ;-)
I'll be filing an LWG issue once we have a draft standard with these bits in it.

Wrapped the string_view bits in #ifdef for C++2a.
De-tabbed.

mclow.lists marked 4 inline comments as done.Nov 28 2017, 5:41 PM
rsmith added inline comments.Nov 28 2017, 5:54 PM
include/string_view
577

You can get a copy of the new draft a few days early from here: https://github.com/cplusplus/draft/blob/master/papers/n4713.pdf

mclow.lists added inline comments.Nov 28 2017, 6:07 PM
include/string_view
577

Thanks. I can also build it myself; but I'd like to refer to it in the issue, so I can wait a day or two.

mclow.lists accepted this revision.Dec 4 2017, 12:12 PM
This revision is now accepted and ready to land.Dec 4 2017, 12:12 PM
mclow.lists closed this revision.Dec 4 2017, 12:12 PM

Committed as revision 319687