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

F.45 needs another exception for rvalue overloads

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
38/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp
領域
documentation

調査の方向性

C++ Core Guidelines のルール F.45 に対応するソースエントリから始め、現在の文言を提案されている例外と比較します。std::get(std::tuple) や std::optional::value() などのメンバーアクセサーに対する rvalue-reference オーバーロードをガイダンスが認め、提案と整合する文言になっていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

F.45 is titled "Don’t return a T&&" and states:

We don’t know of any other good examples [besides std::move] of returning &&.

This is ignorant of functions such as:

The recommendations of CppCoreGuidelines shouldn't contradict common practice in modern C++ standard library features. One could argue that even the standard library uses are illegitimate and unsafe, and there is truth to that. However, the user would incur unjust cost for code such as:

// if .value() returned a value instead of an rvalue reference,
// this would unnecessarily create a temporary object
vec.emplace(get_optional().value());

The zero-overhead principle, a core design principle of the language from the very start arguably trumps the slight safety benefit of returning a value.

Proposed Changes

-We don’t know of any other good examples of returning &&.

+##### Exception
+Member accessors such as `std::get(std::tuple)`,
+or `std::optional::value()` have overloads for rvalue references,
+and those overloads return rvalue references.
+This is fine because it simply imitates what happens when accessing a member of an rvalue struct,
+or a member of an rvalue array.
主要言語
CSS
スター
45.3k
フォーク
5.6k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

isocpp/CppCoreGuidelines のほかの issue

isocpp/CppCoreGuidelines の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

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

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