An rvalue boost::span doesn't work for algorithms that expect mutable ranges
まだ誰も着手していません。
評価
調査の方向性
まず提供された例をコンパイルし、その後 boost/core/span.hpp と boost/range/algorithm/fill.hpp を調べます。rvalue span に対して使用される boost::begin と boost::end のオーバーロードを追跡し、lvalue の経路と比較します。mutable アルゴリズムが rvalue span を受け入れ、コンテナの動作が変更されないまま、両方のケースをカバーできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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 <vector>
#include <boost/core/span.hpp>
#include <boost/range/algorithm/fill.hpp>
template <typename T>
boost::span<T> to_span( std::vector<T>& v ) {
return v;
}
int main() {
std::vector<unsigned char> vec{ 1, 2, 3, 4, 5 };
boost::span<unsigned char> 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.
- 主要言語
- C++
- スター
- 45
- フォーク
- 104
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/range のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Bad is_sorted docs オープン
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
ros2/message_filters#338 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
subsurface/subsurface#4984 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
google-ai-edge/LiteRT-LM#3739 ·