-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't assume string_view::iterator is const char* #2324
Don't assume string_view::iterator is const char* #2324
Conversation
b22cdbe
to
7900a1e
Compare
21e7cf3
to
4a45f97
Compare
// TODO: find something platform independent that is less ugly. | ||
// Or maybe revisit the place where we need this and see if they could | ||
// be actually represented by a const char * nullptr. | ||
inline absl::string_view::iterator string_view_null_iterator() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably in a different file; or in no file at all, just using absl::string_view::iterator{}
everywhere (but that would then be less explicit).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe place in common/strings
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I narrowed its use to anything that anyway uses format-token.h
, so decided to leave it there for now.
(otherwise it would be a bit awkward to have a strings/null-iterator.h
with a single inlined one-liner function in it...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the general direction of this clean-up.
// TODO: find something platform independent that is less ugly. | ||
// Or maybe revisit the place where we need this and see if they could | ||
// be actually represented by a const char * nullptr. | ||
inline absl::string_view::iterator string_view_null_iterator() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe place in common/strings
?
4a45f97
to
fbda6cc
Compare
There were a few assumptions in the code that these types are equivalent, but they are not on all platforms. The fixes sometimes involve ugly `&*some_iterator` constructs to get to the underlying location. Some of these should be re-considered after switching to c++20. We also have a `string_view_null_iterator()` function to generate an iterator that is not initialized to be used in place where we previously used comparison against nullptr. Issues: chipsalliance#2323
fbda6cc
to
ecc7bdc
Compare
Now that we're compatible with all systems after PR chipsalliance#2324, can switch to use std::string_view now.
Now that we're compatible with all systems after PR chipsalliance#2324, can switch to use std::string_view now.
There were a few assumptions in the code that these types are equivalent, but they are not on all platforms.
The fixes sometimes involve ugly
&*some_iterator
constructs to get to the underlying location. Some of these should be re-considered after switching to c++20.Issues: #2323