An rvalue boost::span doesn't work for algorithms that expect mutable ranges
- Dominant language
- C++
- Stars
- 45
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
An rvalue span does not work for algorithms that modify elements. In the following example, using an lvalue span works, but using an rvalue span fails to compile.
```
#include
#include
#include
template
boost::span to_span( std::vector& v ) {
return v;
}
int main() {
std::vector vec{ 1, 2, 3, 4, 5 };
boost::span sp{ vec };
boost::fill( sp, 0 ); // works
boost::fill( to_span(vec), 0); // fails
return 0;
}
```
It looks to me that the issue is that `boost::begin` and `boost::end` have overloads for lvalue ranges and const lvalue ranges but not rvalue ranges, so if you pass an rvalue range to an algorithm, it gets treated as a const lvalue range and has const iterators. That seems to be the right thing to do for containers, but not so much for proxy types like span.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.