Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

An rvalue boost::span doesn't work for algorithms that expect mutable ranges

オープン
#149 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
tooling

調査の方向性

まず提供された例をコンパイルし、その後 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 はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/range のほかの issue

boostorg/range の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。