Skip to content

Commit

Permalink
P23227R0とCWG2654について追記
Browse files Browse the repository at this point in the history
  • Loading branch information
onihusube committed Jun 8, 2023
1 parent 8794a91 commit 2e52939
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lang/cpp20/deprecating_volatile.md
Expand Up @@ -7,7 +7,7 @@ C++20より、`volatile`の本来の役割に照らして不正確、あるい

非推奨となるのは次のもの

1. `volatile`値に対する複合代入演算子(算術型・ポインタ型のみ)
1. ~~`volatile`値に対する複合代入演算子(算術型・ポインタ型のみ)~~
2. `volatile`値に対するインクリメント/デクリメント演算子(算術型・ポインタ型のみ)
3. 間に`volatile`値がある場合の連鎖した代入演算子(非クラス型のみ)
4. 関数引数のトップレベル`volatile`修飾
Expand Down Expand Up @@ -66,6 +66,8 @@ a--;

この場合、これらの複合的な演算子を用いず、明示的に「読み出し - 更新 - 書き込み」を分けて書くことで`volatile`変数へのアクセスをコード上でも明確にする事が推奨される。

ただし、複合代入演算子についてはC++23で非推奨化が解除された。

### 連鎖した代入演算子

代入演算子の一部の用法には、複合代入演算子・インクリメント演算子と同様の問題がある。
Expand Down Expand Up @@ -377,3 +379,5 @@ volatile device dev;
- [P1152R4 Deprecating `volatile`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1152r4.html)
- [P1831R0 Deprecating `volatile`: library](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1831r0.html)
- [P1831R0 Deprecating `volatile`: library](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1831r1.html)
- [P2327R0 De-deprecating volatile compound assignment](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2327r1.pdf)
- [CWG Issue 2654. Un-deprecation of compound volatile assignments](https://cplusplus.github.io/CWG/issues/2654.html)

0 comments on commit 2e52939

Please sign in to comment.