F.45 needs another exception for rvalue overloads
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 38/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- cpp
調査の方向性
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 はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
isocpp/CppCoreGuidelines のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
isocpp/CppCoreGuidelines#2338 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
isocpp/CppCoreGuidelines#2205 · コメント 8 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 64/100
isocpp/CppCoreGuidelines#1649 · コメント 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
isocpp/CppCoreGuidelines#2336 · コメント 4 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
isocpp/CppCoreGuidelines#2335 · コメント 2 件 ·
isocpp/CppCoreGuidelines の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
letsencrypt/cp-cps#353 ·
-
Link Checker Reportオープンautomated issue report
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
[Docs] - Document minimum Terraform/OpenTofu version (>= 1.11) required by write-only argumentsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
MagaluCloud/terraform-provider-mgc#323 ·
メンテナーはふだん 11 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信