Skip to content

Commit b74d3e8

Browse files
committed
execution: get_allocator (#1384)
1 parent d512f5b commit b74d3e8

File tree

7 files changed

+89
-7
lines changed

7 files changed

+89
-7
lines changed

reference/execution/execution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace std::execution {
3636
| 名前 | 説明 | 対応バージョン |
3737
|------|------|----------------|
3838
| [`forwarding_query`](forwarding_query.md.nolink) | クエリオブジェクトに転送問い合わせ可能か否かを返す (customization point object) | C++26 |
39-
| [`get_allocator`](get_allocator.md.nolink) | アロケータ取得のクエリオブジェクト (customization point object) | C++26 |
39+
| [`get_allocator`](get_allocator.md) | アロケータ取得のクエリオブジェクト (customization point object) | C++26 |
4040
| [`get_stop_token`](get_stop_token.md) | 停止トークン取得のクエリオブジェクト (customization point object) | C++26 |
4141
| [`stop_token_of_t`](stop_token_of_t.md) | 指定型から停止トークン型を取得 (alias template) | C++26 |
4242
| [`execution::get_domain`](execution/get_domain.md.nolink) | 実行ドメイン取得のクエリオブジェクト (customization point object) | C++26 |

reference/execution/execution/env.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int main()
6161
```
6262
* ex::env[color ff0000]
6363
* ex::prop[link prop.md]
64-
* std::get_allocator[link get_allocator.md.nolink]
64+
* std::get_allocator[link ../get_allocator.md]
6565
* std::get_stop_token[link ../get_stop_token.md]
6666
* std::never_stop_token[link /reference/stop_token/never_stop_token.md]
6767

reference/execution/execution/env/query.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ constexpr decltype(auto) query(QueryTag q) const noexcept(see below);
1212
* see below[italic]
1313
1414
## 概要
15-
クエリオブジェクト`q`をキーとして、対応する値を問い合わせる。
15+
[クエリオブジェクト](../../queryable.md)`q`をキーとして、対応する値を問い合わせる。
1616
1717
1818
## テンプレートパラメータ制約
@@ -69,7 +69,7 @@ int main()
6969
* query[color ff0000]
7070
* ex::env[link ../env.md]
7171
* ex::prop[link ../prop.md]
72-
* std::get_allocator[link get_allocator.md.nolink]
72+
* std::get_allocator[link ../../get_allocator.md]
7373
* std::get_stop_token[link ../../get_stop_token.md]
7474
* std::never_stop_token[link /reference/stop_token/never_stop_token.md]
7575
* std::stop_token[link /reference/stop_token/stop_token.md]

reference/execution/execution/get_env.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace std::execution {
2222
## 効果
2323
式`get_env(o)`は下記と等価であり、[`queryable`](../queryable.md)を満たす型の値となる。
2424
25-
- 引数`o`がconst修飾された`co`を用いて、式`co.get_env()`が有効であればその値
25+
- 引数`o`がconst修飾された`co`を用いて、式`co.get_env()`が適格であればその値
2626
- そうでなければ、空のクエリ可能オブジェクト[`env<>{}`](env.md)
2727
2828

reference/execution/execution/prop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace std::execution {
2323
* unwrap_reference_t[link /reference/type_traits/unwrap_reference.md]
2424
2525
## 概要
26-
`QueryTag`型クエリオブジェクトのキーと`ValueType`型の値から、[クエリ可能オブジェクト](../queryable.md)を構築する。
26+
`QueryTag`型[クエリオブジェクト](../queryable.md)のキーと`ValueType`型の値から、[クエリ可能オブジェクト](../queryable.md)を構築する。
2727
2828
2929
## 適格要件
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# get_allocator
2+
* execution[meta header]
3+
* cpo[meta id-type]
4+
* std[meta namespace]
5+
* cpp26[meta cpp]
6+
7+
```cpp
8+
namespace std {
9+
struct get_allocator_t { unspecified };
10+
constexpr get_allocator_t get_allocator{};
11+
}
12+
```
13+
* unspecified[italic]
14+
15+
## 概要
16+
`get_allocator`は、[クエリ可能オブジェクト](queryable.md)からアロケータを取得する[クエリオブジェクト](queryable.md)である。
17+
18+
コア定数式[`forwarding_query`](forwarding_query.md.nolink)`(get_allocator)`は`true`値を返す。
19+
20+
21+
## 効果
22+
式`get_allocator(env)`は下記と等価であり、説明専用コンセプト`simple-allocator`を満たす型の値となる。
23+
24+
- 引数`env`がconst修飾された`cenv`を用いて、式`cenv.query(get_allocator)`が適格であること。
25+
26+
```cpp
27+
template<class Alloc>
28+
concept simple-allocator =
29+
requires(Alloc alloc, size_t n) {
30+
{ *alloc.allocate(n) } -> same_as<typename Alloc::value_type&>;
31+
{ alloc.deallocate(alloc.allocate(n), n) };
32+
} &&
33+
copy_constructible<Alloc> &&
34+
equality_comparable<Alloc>;
35+
```
36+
37+
38+
## 例外
39+
投げない
40+
41+
42+
## カスタマイゼーションポイント
43+
const修飾[クエリ可能オブジェクト](queryable.md)`env`に対して式`env.query(get_allocator)`が呼び出される。
44+
このとき、`noexcept(cenv.query(get_allocator)) == true`であること。
45+
46+
47+
##
48+
```cpp
49+
#include <concepts>
50+
#include <memory>
51+
#include <execution>
52+
namespace ex = std::execution;
53+
54+
int main()
55+
{
56+
auto env = ex::prop(std::get_allocator, std::allocator<int>{});
57+
58+
auto alloc = std::get_allocator(env);
59+
static_assert(std::same_as<decltype(alloc), std::allocator<int>>);
60+
}
61+
```
62+
* std::get_allocator[color ff0000]
63+
* ex::prop[link execution/prop.md]
64+
65+
### 出力
66+
```
67+
```
68+
69+
70+
## バージョン
71+
### 言語
72+
- C++26
73+
74+
### 処理系
75+
- [Clang](/implementation.md#clang): ??
76+
- [GCC](/implementation.md#gcc): ??
77+
- [ICC](/implementation.md#icc): ??
78+
- [Visual C++](/implementation.md#visual_cpp): ??
79+
80+
81+
## 参照
82+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

reference/execution/get_stop_token.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace std {
2121
## 効果
2222
式`get_stop_token(env)`は下記と等価であり、[`stoppable_token`](/reference/stop_token/stoppable_token.md)を満たす型の値となる。
2323
24-
- 引数`env`がconst修飾された`cenv`を用いて、式`cenv.query(get_stop_token)`が有効であればその値
24+
- 引数`env`がconst修飾された`cenv`を用いて、式`cenv.query(get_stop_token)`が適格であればその値
2525
- そうでなければ、[`never_stop_token{}`](/reference/stop_token/never_stop_token.md)
2626
2727

0 commit comments

Comments
 (0)