Skip to content

Commit

Permalink
atomic, atomic_ref : C++23 拡張浮動小数点数型に対応 #1022
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed Mar 2, 2023
1 parent 0216351 commit 828ff58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
18 changes: 14 additions & 4 deletions reference/atomic/atomic.md
Expand Up @@ -6,11 +6,11 @@

```cpp
namespace std {
template<class T> struct atomic;
template<class T> struct atomic; // (1) C++11

template<> struct atomic<integral>;
template<> struct atomic<floating-point>; // C++20
template<class T> struct atomic<T*>;
template<> struct atomic<integral>; // (2) C++11
template<> struct atomic<floating-point>; // (3) C++20
template<class T> struct atomic<T*>; // (4) C++11
}
```
* integral[italic]
Expand All @@ -19,6 +19,14 @@ namespace std {
## 概要
`atomic`クラステンプレートは、型`T`をアトミック操作するためのクラステンプレートである。組み込み型に対する特殊化が提供されており、それぞれに特化した演算が用意されている。
- (1) : プライマリテンプレート。宣言のみ
- (2) : 整数型に対する特殊化
- (3) : (CV修飾されていない) 浮動小数点数型に対する特殊化
- (C++23) : 拡張浮動小数点数型を含む
- (4) : 任意の型のポインタに対する特殊化
これらのほか、[`<memory>`](/reference/memory.md)ヘッダで[`std::shared_ptr`と`std::weak_ptr`に対する`atomic`クラスの特殊化](/reference/memory/atomic.md)が定義される。
## テンプレートパラメータ制約
- 型`T`は[コピー構築可能](/reference/concepts/copy_constructible.md)かつ[コピー代入可能](/reference/type_traits/is_copy_assignable.md)であること
Expand Down Expand Up @@ -304,3 +312,5 @@ int main()
- [Correctly implementing a spinlock in C++](https://rigtorp.se/spinlock/)
- [P1135R6 The C++20 Synchronization Library](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1135r6.html)
- C++20での`atomic_signed_lock_free``atomic_unsigned_lock_free`の追加
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で拡張浮動小数点数型もテンプレート引数として指定することが許可された
16 changes: 12 additions & 4 deletions reference/atomic/atomic_ref.md
Expand Up @@ -6,11 +6,11 @@

```cpp
namespace std {
template<class T> struct atomic_ref;
template<class T> struct atomic_ref; // (1) C++20

template<> struct atomic_ref<integral>;
template<> struct atomic_ref<floating-point>;
template<class T> struct atomic_ref<T*>;
template<> struct atomic_ref<integral>; // (2) C++20
template<> struct atomic_ref<floating-point>; // (3) C++20
template<class T> struct atomic_ref<T*>; // (4) C++20
}
```
* integral[italic]
Expand All @@ -27,6 +27,12 @@ namespace std {
`atomic_ref`クラステンプレートは型`T`の値をコピーではなく参照で保持するため、`atomic_ref`オブジェクトより先に参照先の変数の寿命が尽きてはならない。
- (1) : プライマリテンプレート。宣言のみ
- (2) : 整数型に対する特殊化
- (3) : (CV修飾されていない) 浮動小数点数型に対する特殊化
- (C++23) : 拡張浮動小数点数型を含む
- (4) : 任意の型のポインタに対する特殊化
## テンプレートパラメータ制約
- 型`T`は[`is_trivially_copyable_v`](/reference/type_traits/is_trivially_copyable.md)`<T> == true`であること
Expand Down Expand Up @@ -185,3 +191,5 @@ int main()

### 参照
- [P0019R8 Atomic Ref](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0019r8.html)
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で拡張浮動小数点数型もテンプレート引数として指定することが許可された

0 comments on commit 828ff58

Please sign in to comment.