Comments (3)
Given the feedback in boostorg/core#113, I kind of agree that the second constructor is probably a bad idea. The first one requires a modern standard library as it must only compile for contiguous iterators, which is C++20 I think. We currently don't have the infrastructure for this. I don't find the third one very useful, but fine, I guess.
from utility.
I agree on the third one.
Let's accept this as not desirable for now. In reality, the purpose of string_view alternatives outside the standard library are either supporting older compilers (so the missing c++20+ constructors are moot) or adding interoperability benefits (e.g. core::string_view
).
from utility.
What about adding a more restricted version of the first constructor?
explicit constexpr basic_string_view(const_iterator first, const_iterator last);
This would at least provide compatibility with iterator_range
's copy_range
and as a result make string_view
usable with string algorithms without needing to do a follow up conversion. Take for example this reduced example taken from code we're actually using (where we're forced to have an intermediate std::vector<boost::iterator_range<const char*>>
to convert from):
auto do_split(boost::string_view str) {
std::vector<boost::string_view> tokens;
boost::split(tokens, str, [](const char c) { return c == ','; });
return tokens;
}
This would seemingly provide partial forward compatibility with C++20's constructor without creating backwards compatibility problems in the future (that I can see).
Edit: I added this as a comment on boostorg/core#113 (comment). But I was unaware that's a different string_view
than this one.
from utility.
Related Issues (20)
- boost::phoenix::bind issue in c++17. HOT 4
- [MSVC][std:c++latest] Boost\libs\utility run tests failed due to error C2666: 'comparible_UDT::operator ==': overloaded functions have similar conversions HOT 1
- Use core/lightwieght-test.
- small library for std::ios HOT 1
- broken link to String Ref in docs HOT 1
- broken doc link HOT 1
- string_view isn't included in the docs
- boost::equality_comparable2 operator== can compile into infinite loop with clang10 and -std=c++2a HOT 37
- compare_pointees.hpp should permit a predicate HOT 2
- string_ref::remove_prefix() doesn't conform with reference HOT 6
- operators_test invokes undefined behavior in random input tests HOT 2
- boost::utility::string_view should name a type HOT 8
- result_of cannot handle member function pointer to __cdecl function
- boost::string_view::max_size() erroneously returns size()
- remove_prefix and remove_suffix overly permissive HOT 7
- add contains member function to boost::string_view
- Critical: erronous noexcept specifications on boost::string_view::compare
- string_view::substr() doesn't default pos=0
- error C2676: Binary '+': 'T' does not define this operator or a conversion to an acceptable type for the predefined operator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from utility.