Containers: implement also StringView and char concatenation #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because why do the extra work with getting a size of the view if we don't need to.
This however results in an ambiguity with
ArrayView<[const ]char> + int
, i.e., when both sides of the expression need an implicit conversion -- then a candidate is either the builtinoperator+(const char*, std::ptrdiff_t)
, oroperator+(StringView, char)
. Possible solutions:ArrayView
to pointer conversion, forcing people to doview.data() + 3
instead ofview + 3
? Needs to be done in a backwards-compatible way however, as a lot of code relies on this... so it's not an immediate solution.StringView
from anArrayView<char>
, which also picks theconst char*
overload)ArrayView
andStringView
? Would make a lot of new APIs nasty (such asPath::write()
no longer accepting string views for data), OTOH could also prevent errors whenwrite()
accidentally gets data first and filename last. A lot of code also relies on this already, meaning it needs backwards compat and thus this is also not an immediate solution.operator+()
toString.h
so we can have it templated and add a nasty SFINAE that picks only directly a StringView. Or a String? Or .... ugh. This would also mean trying to calloperator+()
when onlyStringView.h
is included would fail with "no such operation possible", which isn't really nice to users.