C++17 std::string_view

81 views
Skip to first unread message

Bob Beck

unread,
Jul 26, 2022, 11:50:52 AM7/26/22
to c...@chromium.org, Matt Mueller, David Benjamin, Emily Stark, Hubert Chao, Adam Langley

Hey C++ folks. 

I'm working on the eventual extraction of the core of the chromium X.509 certificate validator to boringssl. The goal being to make the verifier available in a supportable more widespread place
outside of chrome for consumption by google3 and others. 

TL;DR it will end up showing up as a third library built by boringssl that will require a C++ runtime. 
We have moved the core path building and turtles below it into cert/pki from cert/internal. Eventually cert/pki and cert/der will likely (mostly) move to boringssl.  One of
the bigger challenge is "de-basing" this portion of the code to use std:: (or if desperate, absl::, or out own copies in bssl::) classes instead of base:: - as we don't want to bring all of chromium base:: to boringssl when in use outside of chrome. 

With that in mind I'd very much like to be able to use C++17 std::string_view internally to this as well as for the interfaces to it instead of base::StringPiece. 

What are your thoughts about moving C++17 std::string_view from "tbd" to "allowed"

Thanks in advance, 
-Bob


K. Moon

unread,
Jul 26, 2022, 12:38:45 PM7/26/22
to Bob Beck, c...@chromium.org, Matt Mueller, David Benjamin, Emily Stark, Hubert Chao, Adam Langley
I don't know if we have a principled objection to std::string_view; absl::string_view was banned because of poor support for non-std::string strings (16-bit strings are important to Chromium), but I don't think that reason exists now that we've migrated to std::u16string and C++17.

The only other issue I could think of would be security hardening requirements, but I don't think those would apply to std::string_view any more than they do to std::string.

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALA6n3E25QK3f8O%2BsOxsF%3D4r1StggzDBx6RTsyYztoVFu78pGg%40mail.gmail.com.

K. Moon

unread,
Jul 26, 2022, 12:40:40 PM7/26/22
to Bob Beck, c...@chromium.org, Matt Mueller, David Benjamin, Emily Stark, Hubert Chao, Adam Langley
Looks like there's an open bug for StringPiece to string_view conversion: crbug.com/691162

It currently appears to be inactive, but still open.

Peter Kasting

unread,
Jul 26, 2022, 12:46:05 PM7/26/22
to K. Moon, Bob Beck, c...@chromium.org, Matt Mueller, David Benjamin, Emily Stark, Hubert Chao, Adam Langley, Alan Zhao
On Tue, Jul 26, 2022 at 9:38 AM K. Moon <km...@chromium.org> wrote:
The only other issue I could think of would be security hardening requirements, but I don't think those would apply to std::string_view any more than they do to std::string.


IIRC, one such hardening requirement was to CHECK on construction from nullptr.  Migration to string_view was blocked until recently because we didn't have a libcxx where such a check could happen.  That has now changed, and I suspect once the libcxx hardening checks are hooked up for Chromium, we will be unblocked on migrating from StringPiece to string_view.

The next step would be to actually plan and execute the migration.  We'd be unwilling to change the "TBD" to "allowed" on this until we actually had such a plan in place.  I think I got StringPiece's API in line with string_view already so perhaps this is as simple as "first change StringPiece to a type alias to string_view, then do an LSC to search-and-replace the text everywhere".  Usually there are more gotchas than that, however :)

PK

Daniel Cheng

unread,
Jul 26, 2022, 1:07:25 PM7/26/22
to Peter Kasting, K. Moon, Bob Beck, c...@chromium.org, Matt Mueller, David Benjamin, Emily Stark, Hubert Chao, Adam Langley, Alan Zhao
I'm supportive of using std::string_view with a migration plan, but I don't think you should let that block your work on moving components out-of-tree, nor should using it in that specific case require moving std::string_view from tbd to allowed.

Daniel

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.

K. Moon

unread,
Jul 26, 2022, 2:01:31 PM7/26/22
to Daniel Cheng, Peter Kasting, Bob Beck, c...@chromium.org, Matt Mueller, David Benjamin, Emily Stark, Hubert Chao, Adam Langley, Alan Zhao
Perhaps if StringPiece is close enough to std::string_view already, it should be possible to just define an alias in boringssl?
Reply all
Reply to author
Forward
0 new messages