Skip to content

Commit 622ede1

Browse files
committed
fold_left : 説明専用コンセプト定義を1行1制約化など
1 parent c4adceb commit 622ede1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

reference/algorithm/ranges_fold_left.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ namespace std::ranges {
5252
- `r` -- 入力範囲のオブジェクト
5353
- `init` -- 初期値
5454
- `f` -- 適用する二項演算
55-
- `f(std::move(init), *first)`のような呼び出しが可能であり、その戻り値型を`U`とすると
56-
- `f(std::declval<U&&>(), *first)`のような呼び出しも可能である必要がある
55+
- `f(std::move(init), *first)`のような呼び出しが可能であり、その戻り値型のオブジェクトを`acc`とすると
56+
- `f(std::move(acc), *first)`のような呼び出しも可能である必要がある
5757
5858
## テンプレートパラメータ制約
5959
@@ -62,13 +62,16 @@ namespace std::ranges {
6262
```cpp
6363
template<class F, class T, class I, class U>
6464
concept indirectly-binary-left-foldable-impl =
65-
movable<T> && movable<U> &&
66-
convertible_to<T, U> && invocable<F&, U, iter_reference_t<I>> &&
65+
movable<T> &&
66+
movable<U> &&
67+
convertible_to<T, U> &&
68+
invocable<F&, U, iter_reference_t<I>> &&
6769
assignable_from<U&, invoke_result_t<F&, U, iter_reference_t<I>>>;
6870
6971
template<class F, class T, class I>
7072
concept indirectly-binary-left-foldable =
71-
copy_constructible<F> && indirectly_readable<I> &&
73+
copy_constructible<F> &&
74+
indirectly_readable<I> &&
7275
invocable<F&, T, iter_reference_t<I>> &&
7376
convertible_to<invoke_result_t<F&, T, iter_reference_t<I>>,
7477
decay_t<invoke_result_t<F&, T, iter_reference_t<I>>>> &&
@@ -85,6 +88,10 @@ concept indirectly-binary-left-foldable =
8588
* invoke_result_t[link /reference/type_traits/invoke_result.md]
8689
* decay_t[link /reference/type_traits/decay.md]
8790

91+
ここでのテンプレートパラメータはそれぞれ、二項演算を指定する呼出可能な型`F`、初期値の型`T`、イテレータ型`I`、戻り値型(積算値の型)`U`である。
92+
93+
二項演算(`F`)は初期値・積算値と入力範囲の参照型に対して[`invocable`](/reference/concepts/invocable.md)であることしか求められていない(`regular_invocable`ではない)ため、適用する二項演算は任意の副作用を伴っていても良い。
94+
8895
## 戻り値
8996

9097
- (1) : 以下と等価

0 commit comments

Comments
 (0)