diff --git a/lang/cpp14/feature_test_macros.md b/lang/cpp14/feature_test_macros.md index dab1b7845a..fe53c34a4a 100644 --- a/lang/cpp14/feature_test_macros.md +++ b/lang/cpp14/feature_test_macros.md @@ -49,3 +49,5 @@ SD-6 は C++14 の機能について以下のテストマクロを定義する ## 参照 - [SD-6: SG10 Feature Test Recommendations: Standard C++](https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#recs.cpp14) +- [LWG Issue 3122. `__cpp_lib_chrono_udls` was accidentally dropped](https://cplusplus.github.io/LWG/issue3122) + - C++20のドラフト作業中に誤って削除されていた機能テストマクロ`__cpp_lib_chrono_udls`(値`201304L`)が復活された diff --git a/lang/cpp17/feature_test_macros.md b/lang/cpp17/feature_test_macros.md index e3b24f456a..5a5bfae57a 100644 --- a/lang/cpp17/feature_test_macros.md +++ b/lang/cpp17/feature_test_macros.md @@ -99,3 +99,5 @@ SD-6 は C++17 の機能について以下のテストマクロを定義する ## 参照 - [SD-6: SG10 Feature Test Recommendations: Standard C++](https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#recs.cpp17) +- [LWG Issue 3137. Header for `__cpp_lib_to_chars`](https://cplusplus.github.io/LWG/issue3137) + - C++20で、`__cpp_lib_to_chars`が定義されるヘッダの記載が``から``に修正された diff --git a/lang/cpp20/feature_test_macros.md b/lang/cpp20/feature_test_macros.md index 2959157493..93467704f7 100644 --- a/lang/cpp20/feature_test_macros.md +++ b/lang/cpp20/feature_test_macros.md @@ -88,7 +88,7 @@ |`__cpp_lib_latch`|`201907L`|[`std::latch`](/reference/latch/latch.md)|[``](/reference/latch.md)| |`__cpp_lib_list_remove_return_type`|`201806L`|[`std::list`](/reference/list/list.md)と[`std::forward_list`](/reference/forward_list/forward_list.md)の`remove(), remove_if(), unique()`の戻り値型変更|[``](/reference/forward_list.md)
[``](/reference/list.md)| |`__cpp_lib_math_constants`|`201907L`|数学定数|[``](/reference/numbers.md)| -|`__cpp_lib_polymorphic_allocator`|`201902L`|[`std::pmr::polymorphic_allocator`](/reference/memory_resource/polymorphic_allocator.md)の改修|[``](/reference/memory.md)| +|`__cpp_lib_polymorphic_allocator`|`201902L`|[`std::pmr::polymorphic_allocator`](/reference/memory_resource/polymorphic_allocator.md)の改修|[``](/reference/memory_resource.md)| |`__cpp_lib_ranges`|`201911L`
`202106L`
`202110L`|RangeライブラリとRangeアルゴリズム
[`view`](/reference/ranges/view.md)コンセプトのデフォルト構築要求を削除
所有権を持つ`view`の許可と[`owning_view`](/reference/ranges/owning_view.md)|[``](/reference/algorithm.md)
[``](/reference/functional.md)
[``](/reference/iterator.md)
[``](/reference/memory.md)
[``](/reference/ranges.md)| |`__cpp_lib_remove_cvref`|`201711L`|[`std::remove_cvref`](/reference/type_traits/remove_cvref.md)|[``](/reference/type_traits.md)| |`__cpp_lib_semaphore`|`201907L`|[`std::counting_semaphore`](/reference/semaphore/counting_semaphore.md)と`std::binary_semaphore`|[``](/reference/semaphore.md)| @@ -110,6 +110,14 @@ ## 参照 - [SD-FeatureTest: Feature-Test Macros and Policies - isocpp](https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations) +- [LWG Issue 3437. `__cpp_lib_polymorphic_allocator` is in the wrong header](https://cplusplus.github.io/LWG/issue3437) + - C++23で、`__cpp_lib_polymorphic_allocator`が定義されるヘッダの記載が``から``に修正された +- [LWG Issue 3257. Missing feature testing macro update from P0858](https://cplusplus.github.io/LWG/issue3257) + - C++20で、`__cpp_lib_array_constexpr`が`201803L`に、`__cpp_lib_string_view`が`201803L`に更新された +- [LWG Issue 3274. Missing feature test macro for ``](https://cplusplus.github.io/LWG/issue3274) + - C++20で、機能テストマクロ`__cpp_lib_span`が追加された(最終的な値は後続の提案文書により`202002L`) +- [LWG Issue 3256. Feature testing macro for `constexpr` algorithms](https://cplusplus.github.io/LWG/issue3256) + - C++20で、機能テストマクロ名が`__cpp_lib_constexpr_swap_algorithms`から`__cpp_lib_constexpr_algorithms`にリネームされた - [LWG Issue 3792. `__cpp_lib_constexpr_algorithms` should also be defined in ``](https://cplusplus.github.io/LWG/issue3792) - C++23で、`__cpp_lib_constexpr_algorithms`の定義ヘッダに[``](/reference/utility.md)が追加された(値`201806L`は不変。C++20へ遡及適用される) - [LWG Issue 4440. Forward declarations of entities need also in entries](https://cplusplus.github.io/LWG/issue4440) diff --git a/reference/algorithm/ranges_min_max_result.md b/reference/algorithm/ranges_min_max_result.md index ef9c55233b..8888d1402e 100644 --- a/reference/algorithm/ranges_min_max_result.md +++ b/reference/algorithm/ranges_min_max_result.md @@ -94,3 +94,5 @@ int main() ## 参照 - [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms) +- [LWG Issue 3180. Inconsistently named return type for `ranges::minmax_element`](https://cplusplus.github.io/LWG/issue3180) + - C++20で、`ranges::minmax_element`の戻り値型のエイリアス名が`minmax_result`から`minmax_element_result`に改名され、命名の一貫性が確保された diff --git a/reference/algorithm/ranges_next_permutation.md b/reference/algorithm/ranges_next_permutation.md index 5ce95dbe55..5d20730179 100644 --- a/reference/algorithm/ranges_next_permutation.md +++ b/reference/algorithm/ranges_next_permutation.md @@ -116,3 +116,5 @@ int main () ## 参照 - [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms) +- [LWG Issue 3169. Ranges permutation generators discard useful information](https://cplusplus.github.io/LWG/issue3169) + - C++20で、`ranges::next_permutation`/`ranges::prev_permutation`の戻り値が`bool`から、順列生成後の終端イテレータも返す結果型に変更された diff --git a/reference/algorithm/ranges_partial_sort_copy.md b/reference/algorithm/ranges_partial_sort_copy.md index 6ba612c0aa..c016d199a2 100644 --- a/reference/algorithm/ranges_partial_sort_copy.md +++ b/reference/algorithm/ranges_partial_sort_copy.md @@ -194,3 +194,5 @@ int main() { ## 参照 - [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms) - [P3179R9 C++ parallel range algorithms](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3179r9.html) +- [LWG Issue 3186. Ranges `remove`, `partition`, and `partial_sort_copy` algorithms discard useful information](https://cplusplus.github.io/LWG/issue3186) + - C++20で、これらのアルゴリズムが処理後の終端イテレータ等の有用な情報を返すよう、戻り値が`subrange`や結果型に変更された diff --git a/reference/algorithm/ranges_partition.md b/reference/algorithm/ranges_partition.md index 5093e3f848..11d105ae34 100644 --- a/reference/algorithm/ranges_partition.md +++ b/reference/algorithm/ranges_partition.md @@ -174,3 +174,5 @@ odd: 5 3 7 1 - [P3179R9 C++ parallel range algorithms](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3179r9.html) - [LWG Issue 4297. Missing `permutable` constraint for iterator overloads in Parallel Range Algorithms](https://cplusplus.github.io/LWG/issue4297) - C++26で、並列版のイテレータオーバーロード(3)に`permutable`制約が追加された(範囲版(4)にはあったが、イテレータ版で欠落していたものの修正) +- [LWG Issue 3186. Ranges `remove`, `partition`, and `partial_sort_copy` algorithms discard useful information](https://cplusplus.github.io/LWG/issue3186) + - C++20で、これらのアルゴリズムが処理後の終端イテレータ等の有用な情報を返すよう、戻り値が`subrange`や結果型に変更された diff --git a/reference/algorithm/ranges_prev_permutation.md b/reference/algorithm/ranges_prev_permutation.md index ac3129c44a..b9c7cb56ff 100644 --- a/reference/algorithm/ranges_prev_permutation.md +++ b/reference/algorithm/ranges_prev_permutation.md @@ -112,3 +112,5 @@ int main () ## 参照 - [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms) +- [LWG Issue 3169. Ranges permutation generators discard useful information](https://cplusplus.github.io/LWG/issue3169) + - C++20で、`ranges::next_permutation`/`ranges::prev_permutation`の戻り値が`bool`から、順列生成後の終端イテレータも返す結果型に変更された diff --git a/reference/algorithm/ranges_remove.md b/reference/algorithm/ranges_remove.md index d55c2af512..ba880d7c44 100644 --- a/reference/algorithm/ranges_remove.md +++ b/reference/algorithm/ranges_remove.md @@ -257,3 +257,5 @@ int main() { - [P3179R9 C++ parallel range algorithms](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3179r9.html) - [LWG Issue 4297. Missing `permutable` constraint for iterator overloads in Parallel Range Algorithms](https://cplusplus.github.io/LWG/issue4297) - C++26で、並列版のイテレータオーバーロード(3)に`permutable`制約が追加された(範囲版(4)にはあったが、イテレータ版で欠落していたものの修正) +- [LWG Issue 3186. Ranges `remove`, `partition`, and `partial_sort_copy` algorithms discard useful information](https://cplusplus.github.io/LWG/issue3186) + - C++20で、これらのアルゴリズムが処理後の終端イテレータ等の有用な情報を返すよう、戻り値が`subrange`や結果型に変更された diff --git a/reference/algorithm/ranges_remove_if.md b/reference/algorithm/ranges_remove_if.md index 1d4a3b064b..b4577d7beb 100644 --- a/reference/algorithm/ranges_remove_if.md +++ b/reference/algorithm/ranges_remove_if.md @@ -173,3 +173,5 @@ int main() { - [P3179R9 C++ parallel range algorithms](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3179r9.html) - [LWG Issue 4297. Missing `permutable` constraint for iterator overloads in Parallel Range Algorithms](https://cplusplus.github.io/LWG/issue4297) - C++26で、並列版のイテレータオーバーロード(3)に`permutable`制約が追加された(範囲版(4)にはあったが、イテレータ版で欠落していたものの修正) +- [LWG Issue 3186. Ranges `remove`, `partition`, and `partial_sort_copy` algorithms discard useful information](https://cplusplus.github.io/LWG/issue3186) + - C++20で、これらのアルゴリズムが処理後の終端イテレータ等の有用な情報を返すよう、戻り値が`subrange`や結果型に変更された diff --git a/reference/algorithm/ranges_shuffle.md b/reference/algorithm/ranges_shuffle.md index 4c5ef40ef4..12077ad02b 100644 --- a/reference/algorithm/ranges_shuffle.md +++ b/reference/algorithm/ranges_shuffle.md @@ -130,3 +130,5 @@ before: 0123456789abcdef ## 参照 - [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms) +- [LWG Issue 3191. `std::ranges::shuffle` synopsis does not match algorithm definition](https://cplusplus.github.io/LWG/issue3191) + - C++20で、シノプシスとアルゴリズム定義の不一致を解消するため、冗長な`convertible_to`制約がシノプシスから削除された diff --git a/reference/algorithm/ranges_stable_partition.md b/reference/algorithm/ranges_stable_partition.md index e425a0e815..07dc0cde52 100644 --- a/reference/algorithm/ranges_stable_partition.md +++ b/reference/algorithm/ranges_stable_partition.md @@ -175,3 +175,5 @@ int main() - [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf) - C++26から`constexpr`に対応した - [P3179R9 C++ parallel range algorithms](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3179r9.html) +- [LWG Issue 3186. Ranges `remove`, `partition`, and `partial_sort_copy` algorithms discard useful information](https://cplusplus.github.io/LWG/issue3186) + - C++20で、これらのアルゴリズムが処理後の終端イテレータ等の有用な情報を返すよう、戻り値が`subrange`や結果型に変更された diff --git a/reference/algorithm/ranges_unique.md b/reference/algorithm/ranges_unique.md index ece2fce076..e0ae8029c9 100644 --- a/reference/algorithm/ranges_unique.md +++ b/reference/algorithm/ranges_unique.md @@ -190,3 +190,5 @@ int main() { ## 参照 - [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms) - [P3179R9 C++ parallel range algorithms](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3179r9.html) +- [LWG Issue 3186. Ranges `remove`, `partition`, and `partial_sort_copy` algorithms discard useful information](https://cplusplus.github.io/LWG/issue3186) + - C++20で、これらのアルゴリズムが処理後の終端イテレータ等の有用な情報を返すよう、戻り値が`subrange`や結果型に変更された diff --git a/reference/bitset/bitset/op_istream.md b/reference/bitset/bitset/op_istream.md index c6cc9cae12..f408c32951 100644 --- a/reference/bitset/bitset/op_istream.md +++ b/reference/bitset/bitset/op_istream.md @@ -22,7 +22,11 @@ namespace std { - 次に読み込む文字が`is.widen('0')`と`is.widen('1')`のどちらでもなかった。 2. 読み込んだ文字列`str`を`bitset`のコンストラクタに渡して構築し、`x`に代入する:`x = bitset(str);` -1文字も入力が行われなかった場合、ローカルエラー状態に[`ios_base`](/reference/ios/ios_base.md)`::failbit`を設定する。 +1文字も入力が行われなかった場合の[`ios_base`](/reference/ios/ios_base.md)`::failbit`の設定は、バージョンによって以下のように異なる: + +- C++03 : 1文字も入力が行われなかった場合、`failbit`を設定する +- C++20 : `N > 0`かつ1文字も入力が行われなかった場合に、`failbit`を設定する(`bitset<0>`に対する入力が常に失敗してしまう問題への対処) +- C++23 : `N > 0`かつ1文字も入力が行われなかった場合に、ローカルエラー状態へ`failbit`を設定する ## 戻り値 `is` @@ -53,5 +57,7 @@ int main() ## 参照 +- [LWG Issue 3199. `istream >> bitset<0>` fails](https://cplusplus.github.io/LWG/issue3199) + - C++20で、`failbit`を設定する条件に`N > 0`が追加された。これにより`bitset<0>`に対する入力が常に失敗してしまう問題が修正された - [P1264R2 Revising the wording of stream input operations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1264r2.pdf) - C++23でローカルエラー状態の概念が導入され、入力関数のエラー処理セマンティクスが明確化された diff --git a/reference/cmath/isfinite.md b/reference/cmath/isfinite.md index 39e1ebaedb..fe2916e0a4 100644 --- a/reference/cmath/isfinite.md +++ b/reference/cmath/isfinite.md @@ -103,6 +103,8 @@ int main() ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isgreater.md b/reference/cmath/isgreater.md index 4a3f4798fb..63fa38e48f 100644 --- a/reference/cmath/isgreater.md +++ b/reference/cmath/isgreater.md @@ -106,6 +106,8 @@ isgreater(nan, nan) = false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isgreaterequal.md b/reference/cmath/isgreaterequal.md index 59bbdd8145..31016d4cbc 100644 --- a/reference/cmath/isgreaterequal.md +++ b/reference/cmath/isgreaterequal.md @@ -106,6 +106,8 @@ isgreaterequal(nan, nan) = false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isinf.md b/reference/cmath/isinf.md index 54bdfbe176..1f76bca54f 100644 --- a/reference/cmath/isinf.md +++ b/reference/cmath/isinf.md @@ -77,6 +77,8 @@ int main() ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isless.md b/reference/cmath/isless.md index 78bed4d0c3..aa3a5273e6 100644 --- a/reference/cmath/isless.md +++ b/reference/cmath/isless.md @@ -106,6 +106,8 @@ isless(nan, nan) = false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/islessequal.md b/reference/cmath/islessequal.md index d4ab66480f..661314d052 100644 --- a/reference/cmath/islessequal.md +++ b/reference/cmath/islessequal.md @@ -106,6 +106,8 @@ islessequal(nan, nan) = false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/islessgreater.md b/reference/cmath/islessgreater.md index d10f1947ba..98ac4fac45 100644 --- a/reference/cmath/islessgreater.md +++ b/reference/cmath/islessgreater.md @@ -106,6 +106,8 @@ islessgreater(nan, nan) = false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isnan.md b/reference/cmath/isnan.md index 0052da26de..70a27f92c9 100644 --- a/reference/cmath/isnan.md +++ b/reference/cmath/isnan.md @@ -81,6 +81,8 @@ int main() ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isnormal.md b/reference/cmath/isnormal.md index 051ac7fc48..47b4c7c80c 100644 --- a/reference/cmath/isnormal.md +++ b/reference/cmath/isnormal.md @@ -103,6 +103,8 @@ int main() ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/isunordered.md b/reference/cmath/isunordered.md index f1013c2bd6..3c93d80186 100644 --- a/reference/cmath/isunordered.md +++ b/reference/cmath/isunordered.md @@ -89,6 +89,8 @@ isunordered(1, inf) = false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cmath/signbit.md b/reference/cmath/signbit.md index 4b575c401f..9a4864df5b 100644 --- a/reference/cmath/signbit.md +++ b/reference/cmath/signbit.md @@ -105,6 +105,8 @@ nan : false ## 参照 +- [LWG Issue 3051. Floating point classifications were inadvertently changed in P0175](https://cplusplus.github.io/LWG/issue3051) + - C++20で、P0175が誤ってこれらの関数の戻り値型を`bool`から`int`に変更していたのが修正され、`bool`に戻された - [P0533R9 constexpr for `` and ``](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf) - C++23での、一部関数の`constexpr`対応 - [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html) diff --git a/reference/cstddef/max_align_t.md b/reference/cstddef/max_align_t.md index be64e1a27f..2d918bcdd7 100644 --- a/reference/cstddef/max_align_t.md +++ b/reference/cstddef/max_align_t.md @@ -14,7 +14,10 @@ namespace std { ## 概要 `std::max_align_t`のアライメントサイズは、スカラー型の中の最も大きなアライメントサイズと同じかそれ以上である。 -この型は、C++11では[POD型](/reference/type_traits/is_pod.md)、C++20では[トリビアル型](/reference/type_traits/is_trivial.md)に分類される。 +この型は、以下のように分類される: + +- C++11 : [POD型](/reference/type_traits/is_pod.md) +- C++20 : [トリビアル型](/reference/type_traits/is_trivial.md)かつ[標準レイアウト型](/reference/type_traits/is_standard_layout.md) `alignas`指示子により、`std::max_align_t`のアライメントより大きいサイズのアライメントを指定できるかどうかは、実装依存である。 @@ -79,3 +82,5 @@ is_pod: 1 ## 参照 - [P0767R1 Deprecate POD](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0767r1.html) - C++20でPOD用語の非推奨化にともない、この型がPOD型ではなくトリビアル型に分類されるよう規定が変更された +- [LWG Issue 3034. P0767R1 breaks previously-standard-layout types](https://cplusplus.github.io/LWG/issue3034) + - C++20で、P0767R1がPOD要件をトリビアル要件へ置き換えた際に標準レイアウト性が欠落していたため、トリビアルかつ標準レイアウトであることが要件として補われた diff --git a/reference/deque/deque/emplace.md b/reference/deque/deque/emplace.md index d0ec578959..21f34273a4 100644 --- a/reference/deque/deque/emplace.md +++ b/reference/deque/deque/emplace.md @@ -33,7 +33,10 @@ constexpr iterator emplace(const_iterator position, Args&&... args); // (1) C++2 ## 備考 -例外発生時に副作用が発生しない保証は[`insert()`](insert.md)と同様。 +- 例外発生時に副作用が発生しない保証は[`insert()`](insert.md)と同様。 +- 引数`args`がこのコンテナ自身の要素を参照する場合の扱いは、バージョンによって以下のように異なる: + - C++17まで : 引数`args`がコンテナ自身の要素を参照する場合の動作は規定されていない + - C++20 : 引数`args`は、このコンテナ自身の要素を直接的または間接的に参照してもよい。たとえば`c.emplace(c.begin(), c.back())`のように、末尾要素を先頭に挿入する操作も正しく動作する ## 例 @@ -88,3 +91,5 @@ int main() - [LWG Issue 2252. Strong guarantee on `vector::push_back()` still broken with C++11?](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2252) - 経緯の説明は、[`vector::push_back()`](/reference/vector/vector/push_back.md)ページを参照。 - [P3372R3 constexpr containers and adaptors](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3372r3.html) +- [LWG Issue 2164. What are the semantics of `vector.emplace(vector.begin(), vector.back())`?](https://cplusplus.github.io/LWG/issue2164) + - C++20で、引数がコンテナ自身の要素を参照してもよいことが明確化された diff --git a/reference/filesystem/create_directory.md b/reference/filesystem/create_directory.md index 5bb79e6831..fc54600c6f 100644 --- a/reference/filesystem/create_directory.md +++ b/reference/filesystem/create_directory.md @@ -30,6 +30,7 @@ namespace std::filesystem { - (3), (4) : パス`existing_p`の属性を取得し、その属性を付加してパス`p`のディレクトリを作成する - POSIX環境では、[`stat`](https://web.archive.org/web/20230827123440/https://linuxjm.osdn.jp/html/LDP_man-pages/man2/stat.2.html)`(existing_p.c_str(), &attributes_stat)`の呼び出し後に、[`mkdir`](https://web.archive.org/web/20231009095236/https://linuxjm.osdn.jp/html/LDP_man-pages/man2/mkdir.2.html)`(p.c_str(), attributes_stat.st_mode)`の呼び出しでディレクトリを作成する - Windows環境では、`CreateDirectoryExW(existing_p.c_str(), p.c_str(), 0)`を呼び出す +- (1)〜(4) : パス`p`がすでにディレクトリとして存在する場合、ディレクトリの作成は行われず、これはエラーとして扱われない(戻り値は`false`となる) ## 戻り値 @@ -82,3 +83,8 @@ int main() - [Clang](/implementation.md#clang): 7.0 [mark verified] - [GCC](/implementation.md#gcc): 8.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): + + +## 参照 +- [LWG Issue 3079. LWG 2935 forgot to fix the `existing_p` overloads of `create_directory`](https://cplusplus.github.io/LWG/issue3079) + - C++20で、既存アタッチメントを取る`existing_p`版オーバーロードも、指定したパスがすでにディレクトリとして存在する場合にエラーとしないよう修正された diff --git a/reference/filesystem/directory_entry.md b/reference/filesystem/directory_entry.md index 64dcc4a48d..8e101d9519 100644 --- a/reference/filesystem/directory_entry.md +++ b/reference/filesystem/directory_entry.md @@ -69,6 +69,12 @@ namespace std::filesystem { | [`operator>`](directory_entry/op_greater.md) | 左辺が右辺より大きいかの判定を行う | C++17 | | [`operator>=`](directory_entry/op_greater_equal.md) | 左辺が右辺以上かの判定を行う | C++17 | +### ストリーム出力 + +| 名前 | 説明 | 対応バージョン | +|------------------------------------------------------|-------------|-------| +| [`operator<<`](directory_entry/op_ostream.md) | ストリームへの出力 | C++17 | + ## 例 ```cpp example diff --git a/reference/filesystem/directory_entry/op_ostream.md b/reference/filesystem/directory_entry/op_ostream.md new file mode 100644 index 0000000000..0b5766d8aa --- /dev/null +++ b/reference/filesystem/directory_entry/op_ostream.md @@ -0,0 +1,78 @@ +# operator<< +* filesystem[meta header] +* std::filesystem[meta namespace] +* directory_entry[meta class] +* function template[meta id-type] +* cpp17[meta cpp] + +```cpp +namespace std::filesystem { + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, const directory_entry& d); // (1) C++17 +} +``` + +## 概要 +`directory_entry`オブジェクトが指すパスを、出力ストリームに出力する。 + +この演算子は、`directory_entry`クラスの*Hidden friends*として定義される。 + + +## 効果 +以下と等価である: + +```cpp +return os << d.path(); +``` +* d.path()[link path.md] + + +## 戻り値 +`os` + + +## 備考 +この演算子は、[LWG Issue 2989](https://cplusplus.github.io/LWG/issue2989)によって一度削除されたが、それが誤りであったため[LWG Issue 3171](https://cplusplus.github.io/LWG/issue3171)によって復活した。 + + +## 例 +```cpp example +#include +#include +#include + +namespace fs = std::filesystem; + +int main() +{ + fs::create_directory("dir"); + std::ofstream{"dir/a.txt"}; + + fs::directory_entry entry{"dir/a.txt"}; + std::cout << entry << std::endl; +} +``` +* entry[color ff0000] +* fs::create_directory[link /reference/filesystem/create_directory.md] + +### 出力例 +``` +"dir/a.txt" +``` + +## バージョン +### 言語 +- C++17 + +### 処理系 +- [Clang](/implementation.md#clang): +- [GCC](/implementation.md#gcc): 8.1 [mark verified] +- [Visual C++](/implementation.md#visual_cpp): 2017 Update 7 [mark verified] + + +## 参照 +- [LWG Issue 2989. Path's stream insertion operator lets you insert everything under the sun](https://cplusplus.github.io/LWG/issue2989) + - この解決で、`directory_entry`のストリーム挿入演算子が誤って削除された +- [LWG Issue 3171. LWG2989 breaks `directory_entry` stream insertion](https://cplusplus.github.io/LWG/issue3171) + - C++23で、[LWG 2989](https://cplusplus.github.io/LWG/issue2989)が誤って削除した`directory_entry`のストリーム挿入演算子が復活した diff --git a/reference/filesystem/path/compare.md b/reference/filesystem/path/compare.md index 97601cad8b..b3f5f3174e 100644 --- a/reference/filesystem/path/compare.md +++ b/reference/filesystem/path/compare.md @@ -17,7 +17,11 @@ int compare(const value_type* s) const; // (4) ## 戻り値 -- (1) : `this->`[`native()`](native.md)ベースのパスにおける範囲`[`[`begin()`](begin.md)`,` [`end()`](end.md)`)`の各パス要素と`p.`[`native()`](native.md)ベースのパスにおける範囲`[p.`[`begin()`](begin.md)`, p.`[`end()`](end.md)`)`の各パス要素を辞書順比較し、`*this`の方が小さければ0未満の値、`*this`の方が大きければ0より大きい値、等しければ0を返す +- (1) : 以下の順序で比較した結果を返す: + 1. `rootNameComparison`を`this->`[`root_name()`](root_name.md)`.`[`native()`](native.md)`.`[`compare`](/reference/string/basic_string/compare.md)`(p.`[`root_name()`](root_name.md)`.`[`native()`](native.md)`)`とする。`rootNameComparison`が0でなければ、その値を返す + 2. `this->`[`has_root_directory()`](has_root_directory.md)かつ`!p.`[`has_root_directory()`](has_root_directory.md)であれば、0より大きい値を返す + 3. `!this->`[`has_root_directory()`](has_root_directory.md)かつ`p.`[`has_root_directory()`](has_root_directory.md)であれば、0未満の値を返す + 4. `this->`[`relative_path()`](relative_path.md)と`p.`[`relative_path()`](relative_path.md)の範囲`[`[`begin()`](begin.md)`,` [`end()`](end.md)`)`の各パス要素を辞書順比較し、`*this`の方が小さければ0未満の値、`*this`の方が大きければ0より大きい値、等しければ0を返す - (2), (3), (4) : `compare(path(s))`を返す @@ -67,3 +71,8 @@ int main() - [Clang](/implementation.md#clang): - [GCC](/implementation.md#gcc): 8.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2017 Update 7 [mark verified] + + +## 参照 +- [LWG Issue 2936. Path comparison is defined in terms of the generic format](https://cplusplus.github.io/LWG/issue2936) + - C++20で、比較の定義が、ルート名([`native()`](native.md)ベース)・ルートディレクトリの有無・相対パスの辞書順という段階的な比較として明確化された diff --git a/reference/filesystem/path/lexically_relative.md b/reference/filesystem/path/lexically_relative.md index 6ef7bf47fe..30e0c71e2a 100644 --- a/reference/filesystem/path/lexically_relative.md +++ b/reference/filesystem/path/lexically_relative.md @@ -20,14 +20,16 @@ path lexically_relative(const path& base) const; - [`root_name()`](root_name.md) `!= base.`[`root_name()`](root_name.md) - [`is_absolute()`](is_absolute.md) `!= base.`[`is_absolute()`](is_absolute.md) - `!`[`has_root_directory()`](has_root_directory.md) `&& base.`[`has_root_directory()`](has_root_directory.md) + - [`relative_path()`](relative_path.md)または`base.`[`relative_path()`](relative_path.md)のいずれかのファイル名が、ルート名として解釈できる場合(Windowsのように、ファイル名がルート名になりうる環境での誤った解決を防ぐため) 2. 以下の式で、`*this`と`base`が異なる最初の位置を見つける: - `auto [a, b] =` [`std::mismatch`](/reference/algorithm/mismatch.md)`(`[`begin()`](begin.md)`,` [`end()`](end.md)`, base.`[`begin()`](begin.md)`, base.`[`end()`](end.md)`);` 3. `a ==` [`end()`](end.md)かつ`b == base.`[`end()`](end.md)の場合、`path(".")`が返る -4. イテレータ範囲`[b, base.`[`end()`](end.md)`)`の非`"."` (ドットx1) かつ非`".."` (ドットx2) の数から、同範囲内の `".."` の数を引いたものを`n`とする +4. イテレータ範囲`[b, base.`[`end()`](end.md)`)`の非`"."` (ドットx1) かつ非`".."` (ドットx2) かつ非空 (empty) の要素の数から、同範囲内の `".."` の数を引いたものを`n`とする 5. `n < 0`であれば、空のパスが返る -6. 新たな`path`型オブジェクト`p`をデフォルト構築し、 -7. 式`p /= path("..")`をn回を適用する -8. イテレータ範囲`[a,` [`end()`](end.md)`)`の各要素`x`を、式`p /= x`で加算する +6. `n == 0`かつ`(a ==` [`end()`](end.md)`|| a->empty())`の場合、`path(".")`が返る +7. 新たな`path`型オブジェクト`p`をデフォルト構築し、 +8. 式`p /= path("..")`をn回を適用する +9. イテレータ範囲`[a,` [`end()`](end.md)`)`の各要素`x`を、式`p /= x`で加算する ## 備考 @@ -65,3 +67,10 @@ int main() - [Clang](/implementation.md#clang): - [GCC](/implementation.md#gcc): 8.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2017 Update 7 [mark verified] + + +## 参照 +- [LWG Issue 3070. `path::lexically_relative` causes surprising results if a filename can also be a root-name](https://cplusplus.github.io/LWG/issue3070) + - C++20で、相対パス・基準パスのファイル名がルート名として解釈できる場合に空のパスを返す条件が追加され、Windowsのような環境での誤った解決が防がれた +- [LWG Issue 3096. `path::lexically_relative` is confused by trailing slashes](https://cplusplus.github.io/LWG/issue3096) + - C++20で、末尾スラッシュ(空要素)を含むパスで結果が破綻する問題が修正された。要素数の集計から空要素を除外し、`n == 0`かつ末尾が空要素の場合に`path(".")`を返すステップが追加された diff --git a/reference/filesystem/path/op_append.md b/reference/filesystem/path/op_append.md index d7a508195e..c705cb590f 100644 --- a/reference/filesystem/path/op_append.md +++ b/reference/filesystem/path/op_append.md @@ -6,7 +6,12 @@ ```cpp namespace std::filesystem { - path operator/(const path& x, const path& y); + path operator/(const path& lhs, const path& rhs); // (1) C++17 + + class path { + public: + friend path operator/(const path& lhs, const path& rhs); // (1) C++20 + }; } ``` @@ -155,3 +160,8 @@ h : "D:bar" - [Clang](/implementation.md#clang): - [GCC](/implementation.md#gcc): 8.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2017 Update 7 [mark verified] + + +## 参照 +- [LWG Issue 3065. LWG 2989 missed that all path's other operators should be hidden friends as well](https://cplusplus.github.io/LWG/issue3065) + - C++20で、`operator/`が非メンバ関数から*Hidden friends*に変更された。これにより、少なくとも一方の被演算子が`path`型である場合のみ暗黙変換が働くようになり、両辺が同時に暗黙変換される問題が回避された diff --git a/reference/filesystem/path/op_constructor.md b/reference/filesystem/path/op_constructor.md index 35082df2e5..0406fc101b 100644 --- a/reference/filesystem/path/op_constructor.md +++ b/reference/filesystem/path/op_constructor.md @@ -47,6 +47,7 @@ path(InputIterator first, InputIterator last, - [`std::basic_string`](/reference/string/basic_string.md)`` - [`std::basic_string_view`](/reference/string_view/basic_string_view.md)`` - `ECharT`型を要素とする文字配列と、文字配列へのポインタ + - `Source`は`path`以外の型であること(C++20) - これらの要件を満たさない場合、この関数はオーバーロード解決の候補から除外される - `source`はヌルポインタであってはならない - (6), (8) : `InputIterator`が指す値型は`EcharT`であること @@ -199,3 +200,8 @@ int main() ## 関連項目 - [`u8path()`](/reference/filesystem/u8path.md) + + +## 参照 +- [LWG Issue 3244. Constraints for `Source` in [fs.path.req] insufficiently constrainty](https://cplusplus.github.io/LWG/issue3244) + - C++20で、`Source`型の制約に「`path`以外の型であること」という条件が追加され、`path`を`Source`として渡した際の循環参照が排除された diff --git a/reference/filesystem/path/op_plus_assign.md b/reference/filesystem/path/op_plus_assign.md index 16b766c8d7..44e7984493 100644 --- a/reference/filesystem/path/op_plus_assign.md +++ b/reference/filesystem/path/op_plus_assign.md @@ -26,7 +26,8 @@ path& operator+=(EcharT x); // (7) ## 効果 -`path(x).`[`native()`](native.md)を、`*this`が保持するパス文字列に加算する。 +- (1), (2), (3), (4), (6) : `path(x).`[`native()`](native.md)を、`*this`が保持するパス文字列に加算する。 +- (5), (7) : `*this += basic_string_view(&x, 1)`と等価。すなわち、1文字`x`を1要素の文字列ビューとして加算する。 ## 戻り値 @@ -75,3 +76,8 @@ int main() - [Clang](/implementation.md#clang): - [GCC](/implementation.md#gcc): 8.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2017 Update 7 [mark verified] + + +## 参照 +- [LWG Issue 3055. `path::operator+=(single-character)` misspecified](https://cplusplus.github.io/LWG/issue3055) + - C++20で、1文字を加算するオーバーロード(5), (7)の効果が、`*this += basic_string_view(&x, 1)`と等価であるよう修正された(旧規定では1文字からのパス構築が破綻していた) diff --git a/reference/format/basic_format_arg/op_constructor.md b/reference/format/basic_format_arg/op_constructor.md index dba7e2845e..7651efc7be 100644 --- a/reference/format/basic_format_arg/op_constructor.md +++ b/reference/format/basic_format_arg/op_constructor.md @@ -95,3 +95,5 @@ namespace std { - C++23で、コンストラクタが検査する型プロパティをcvref除去後の型で判定するよう整理された(最終的にコンストラクタは左辺値参照`T&`をとり、`TD = remove_const_t`で判定する形になった) - [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html) - C++26から`constexpr`に対応した +- [LWG Issue 3246. What are the constraints on the template parameter of `basic_format_arg`?](https://cplusplus.github.io/LWG/issue3246) + - C++20で、説明専用コンストラクタのテンプレート引数`T`の制約が、対応する`formatter`特殊化がFormatter要件を満たすこと、という表現に整理された diff --git a/reference/forward_list/forward_list/merge.md b/reference/forward_list/forward_list/merge.md index 5e4918eff6..261a3a2233 100644 --- a/reference/forward_list/forward_list/merge.md +++ b/reference/forward_list/forward_list/merge.md @@ -33,7 +33,12 @@ constexpr void merge(forward_list&& x, Compare comp); // (4) C++26 ## 効果 -[`addressof`](/reference/memory/addressof.md)`(x) == this`である場合、何もしない。そうでない場合、2つのソート済みイテレータ範囲`[begin(), end())`と`[x.begin(), x.end())`をマージする。2つの`forward_list`オブジェクトの要素を`*this`に併合し、`x`はマージ後に空となる。 +2つのソート済みイテレータ範囲`[begin(), end())`と`[x.begin(), x.end())`をマージする。2つの`forward_list`オブジェクトの要素を`*this`に併合し、`x`はマージ後に空となる。 + +[`addressof`](/reference/memory/addressof.md)`(x) == this`(自己マージ)の場合の扱いは、バージョンによって異なる。 + +- C++11 : 規定されていない +- C++23 : 何もしない マージ後、`x`の要素に対するイテレータおよび参照は無効にならない。 @@ -47,7 +52,9 @@ constexpr void merge(forward_list&& x, Compare comp); // (4) C++26 ## 計算量 -[`addressof`](/reference/memory/addressof.md)`(x) == this`である場合、比較を行わない。そうでない場合、高々[`distance`](/reference/iterator/distance.md)`(`[`begin`](begin.md)()`,` [`end`](end.md)`()) +` [`distance`](/reference/iterator/distance.md)`(x.`[`begin`](begin.md)`(), x.`[`end`](end.md)`()) - 1`回の比較 +高々[`distance`](/reference/iterator/distance.md)`(`[`begin`](begin.md)()`,` [`end`](end.md)`()) +` [`distance`](/reference/iterator/distance.md)`(x.`[`begin`](begin.md)`(), x.`[`end`](end.md)`()) - 1`回の比較。 + +- C++23 : ただし、[`addressof`](/reference/memory/addressof.md)`(x) == this`である場合は比較を行わない ## 備考 diff --git a/reference/fstream/basic_filebuf/open.md b/reference/fstream/basic_filebuf/open.md index eecf0fbc92..b14df4e705 100644 --- a/reference/fstream/basic_filebuf/open.md +++ b/reference/fstream/basic_filebuf/open.md @@ -24,6 +24,11 @@ basic_filebuf* open(const T& s, ios_base::openmode mode); // (4) C++23 ## テンプレートパラメータ制約 - (4) C++23 : [`is_same_v`](/reference/type_traits/is_same.md)``が`true`であること +## 事前条件 +- (1), (2) : + - C++20 : `s`はヌル終端文字列 (NTCTS) を指していること。 + + ## 効果 まず`mode & ~ios_base::ate`の結果からファイルの開くモードが決定される。`fopen`のモード文字列との対応は以下の通り。 @@ -92,4 +97,5 @@ int main() - [LGW issue 2676. Provide filesystem::path overloads for File-based streams](https://wg21.cmeerw.net/lwg/issue2676) - [LWG Issue 3430. `std::fstream` & co. should be constructible from `string_view`](https://cplusplus.github.io/LWG/issue3430) - C++23で、`filesystem::path`を受け取る`open`(4)が、`path`へ暗黙変換可能な型による高コストな変換を防ぐため、`is_same_v`を制約とする制約付きテンプレートに変更された -- [LGW issue 2943. Problematic specification of the wide version of basic_filebuf::open](https://wg21.cmeerw.net/lwg/issue2943) +- [LWG Issue 2943. Problematic specification of the wide version of `basic_filebuf::open`](https://cplusplus.github.io/LWG/issue2943) + - C++20で、ワイド版`open`の効果が、`fopen`をモード文字列付きで呼び出したかのように振る舞うと明確化された diff --git a/reference/future/async.md b/reference/future/async.md index 1833a95161..45152d4f86 100644 --- a/reference/future/async.md +++ b/reference/future/async.md @@ -206,3 +206,5 @@ foo() = 3 - [<future> functions - Microsoft Docs](https://docs.microsoft.com/en-us/cpp/standard-library/future-functions?view=vs-2019#remarks) - [P2422R1 Remove `nodiscard` annotations from the standard library specification](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2422r1.html) - C++26で`[[nodiscard]]`指定が削除された +- [LWG Issue 3476. `thread` and `jthread` constructors require that the parameters be move-constructible](https://cplusplus.github.io/LWG/issue3476) + - C++23で、`is_constructible`要件が既に目的を満たすため、冗長だったムーブ構築可能(`is_move_constructible`)の要件が削除された diff --git a/reference/future/future.md b/reference/future/future.md index 275d81e897..50b3ec50b4 100644 --- a/reference/future/future.md +++ b/reference/future/future.md @@ -15,6 +15,10 @@ namespace std { `future`は、「別スレッドでの処理完了を待ち、その処理結果を取得する」といった非同期処理を実現するためのクラスであり、[`promise`](promise.md)クラスと組み合わせて使用する。[`promise`](promise.md)が別スレッドでの処理結果を書き込み、`future`がその結果を読み取る。[`promise`](promise.md)と`future`は内部的に同一の共有状態を参照する。これによってスレッド間での値の受け渡しやスレッド間同期を実現する。このクラスは`R&`および`void`の、2つの特殊化を持つ。 +## 適格要件 +- C++23 : `R`が参照型でも`void`でもない場合、`R`はデストラクト可能 (`Cpp17Destructible`) なオブジェクト型であること。配列型・関数型は不適格である。 + + ## メンバ関数 | 名前 | 説明 | 対応バージョン | @@ -105,3 +109,5 @@ int main() ## 参照 +- [LWG Issue 3466. Specify the requirements for `promise`/`future`/`shared_future` consistently](https://cplusplus.github.io/LWG/issue3466) + - C++23で、テンプレート引数`R`がCpp17Destructible要件を満たすオブジェクト型でなければならないという要件が一貫して規定された(配列型・関数型は不適格) diff --git a/reference/future/promise.md b/reference/future/promise.md index ecee0fb361..8706aa1729 100644 --- a/reference/future/promise.md +++ b/reference/future/promise.md @@ -22,6 +22,10 @@ namespace std { - `R` : 結果値の型 +## 適格要件 +- C++23 : `R`が参照型でも`void`でもない場合、`R`はデストラクト可能 (`Cpp17Destructible`) なオブジェクト型であること。配列型・関数型は不適格である。 + + ## メンバ関数 | 名前 | 説明 | 対応バージョン | @@ -124,3 +128,5 @@ int main() ## 参照 +- [LWG Issue 3466. Specify the requirements for `promise`/`future`/`shared_future` consistently](https://cplusplus.github.io/LWG/issue3466) + - C++23で、テンプレート引数`R`がCpp17Destructible要件を満たすオブジェクト型でなければならないという要件が一貫して規定された(配列型・関数型は不適格) diff --git a/reference/future/shared_future.md b/reference/future/shared_future.md index 9c11edd0f8..feaf4969ad 100644 --- a/reference/future/shared_future.md +++ b/reference/future/shared_future.md @@ -15,6 +15,10 @@ namespace std { `shared_future`は、[`future`](future.md)クラスオブジェクトから変換によって生成されるクラスである。[`future`](future.md)オブジェクトが[`promise`](promise.md)との共有状態を単一オブジェクトで待機するのに対し、`shared_future`オブジェクトは同じ共有状態を複数オブジェクトで待機することを可能にする。 +## 適格要件 +- C++23 : `R`が参照型でも`void`でもない場合、`R`はデストラクト可能 (`Cpp17Destructible`) なオブジェクト型であること。配列型・関数型は不適格である。 + + ## メンバ関数 | 名前 | 説明 | 対応バージョン | @@ -108,3 +112,5 @@ int main() ## 参照 +- [LWG Issue 3466. Specify the requirements for `promise`/`future`/`shared_future` consistently](https://cplusplus.github.io/LWG/issue3466) + - C++23で、テンプレート引数`R`がCpp17Destructible要件を満たすオブジェクト型でなければならないという要件が一貫して規定された(配列型・関数型は不適格) diff --git a/reference/ios/ios_base/iword.md b/reference/ios/ios_base/iword.md index 6e3cb3e266..5de1880e2c 100644 --- a/reference/ios/ios_base/iword.md +++ b/reference/ios/ios_base/iword.md @@ -12,6 +12,10 @@ long& iword(int idx); `long` 型の私用記憶域への参照を取得する。 +## 事前条件 +- C++20 : `idx`は、[`xalloc`](xalloc.md)の呼び出しによって取得した値であること。この事前条件を満たさない値(たとえば `-1` )を渡した場合の動作は未規定 + + ## 効果 `idx` で指定した記憶域がまだ確保されていなかった場合、新たに `long` 型の記憶域を確保し、`0` で初期化する。 もし、記憶域の確保に失敗し、かつ、`*this` が [`basic_ios`](../basic_ios.md) の基底サブオブジェクトの場合、[`basic_ios`](../basic_ios.md)`::`[`setstate`](../basic_ios/setstate.md)`(badbit)` を呼び出す(これは [`failure`](failure.md) 例外を送出するかもしれない)。 @@ -22,8 +26,7 @@ long& iword(int idx); ## 備考 -- 引数 `idx` には、[`xalloc`](xalloc.md) で取得した値を渡すことが想定されている。 - そうすることによって、各プログラムが他のプログラムと競合すること無く各ストリームオブジェクト内に `long` 型の私用記憶域を確保することが可能となる。 +- 引数 `idx` に [`xalloc`](xalloc.md) で取得した値を渡すことによって、各プログラムが他のプログラムと競合すること無く各ストリームオブジェクト内に `long` 型の私用記憶域を確保することが可能となる。 - 本関数で取得した `long` への参照は、本オブジェクトの他の操作によって無効になる可能性がある。 しかし、その場合でも引数 `idx` で指定した記憶域の内容は依然として有効である。 - 本関数で取得した `long` 型の記憶域の内容は、[`basic_ios`](../basic_ios.md)`::`[`copyfmt`](../basic_ios/copyfmt.md) でコピーされる。 @@ -110,7 +113,11 @@ int main() ``` -## 参照 +## 関連項目 - [`xalloc`](xalloc.md) - [`pword`](pword.md) - [`basic_ios`](../basic_ios.md)`::`[`copyfmt`](../basic_ios/copyfmt.md) + +## 参照 +- [LWG Issue 3083. What should `ios::iword(-1)` do?](https://cplusplus.github.io/LWG/issue3083) + - C++20で、引数には[`xalloc`](xalloc.md)で取得した値を渡すことが事前条件として明確化された(それ以外の値を渡した場合の動作は未規定) diff --git a/reference/ios/ios_base/op_destructor.md b/reference/ios/ios_base/op_destructor.md index 8231a0cbea..18daf9117a 100644 --- a/reference/ios/ios_base/op_destructor.md +++ b/reference/ios/ios_base/op_destructor.md @@ -13,9 +13,10 @@ virtual ~ios_base(); ## 効果 -オブジェクトを破棄する。 -また、[`register_callback`](register_callback.md) で登録されたペア `(fn, index)` を `(*fn)(`[`erase_event`](type-event.md)`, *this, index)` として呼び出す。 -コールバック関数が呼び出されている間、[`ios_base`](../ios_base.md) のあらゆるメンバ関数呼び出しが有効に機能することが保証されている。 +- オブジェクトを破棄する。 +- また、[`register_callback`](register_callback.md) で登録されたペア `(fn, index)` を `(*fn)(`[`erase_event`](type-event.md)`, *this, index)` として呼び出す。 + - コールバック関数が呼び出されている間、[`ios_base`](../ios_base.md) のあらゆるメンバ関数呼び出しが有効に機能することが保証されている。 +- C++23 : コールバックの呼び出し後、[`iword`](iword.md)・[`pword`](pword.md) のために確保されていたメモリを解放する。 ## バージョン @@ -33,3 +34,5 @@ virtual ~ios_base(); - [`ios_base`](../ios_base.md)`::`[`ios_base`](op_constructor.md) - [`basic_ios`](../basic_ios.md) - [`basic_ios`](../basic_ios.md)`::`[`~basic_ios`](../basic_ios/op_destructor.md) +- [LWG Issue 3434. `ios_base` never reclaims memory for `iarray` and `parray`](https://cplusplus.github.io/LWG/issue3434) + - C++23で、デストラクタの効果に、`iword`・`pword`のために確保したメモリを解放することが追記された diff --git a/reference/ios/ios_base/pword.md b/reference/ios/ios_base/pword.md index de072fa837..ae71daa65b 100644 --- a/reference/ios/ios_base/pword.md +++ b/reference/ios/ios_base/pword.md @@ -12,6 +12,10 @@ void*& pword(int idx); `void*` 型の私用記憶域への参照を取得する。 +## 事前条件 +- C++20 : `idx`は、[`xalloc`](xalloc.md)の呼び出しによって取得した値であること。この事前条件を満たさない値(たとえば `-1` )を渡した場合の動作は未規定 + + ## 効果 `idx` で指定した記憶域がまだ確保されていなかった場合、新たに `void*` 型の記憶域を確保し、ヌルポインタで初期化する。 もし、記憶域の確保に失敗し、かつ、`*this` が [`basic_ios`](../basic_ios.md) の基底サブオブジェクトの場合、[`basic_ios`](../basic_ios.md)`::`[`setstate`](../basic_ios/setstate.md)`(badbit)` を呼び出す(これは [`failure`](failure.md) 例外を送出するかもしれない)。 @@ -22,8 +26,7 @@ void*& pword(int idx); ## 備考 -- 引数 `idx` には、[`xalloc`](xalloc.md) で取得した値を渡すことが想定されている。 - そうすることによって、各プログラムが他のプログラムと競合すること無く各ストリームオブジェクト内に `void*` 型の私用記憶域を確保することが可能となる。 +- 引数 `idx` に [`xalloc`](xalloc.md) で取得した値を渡すことによって、各プログラムが他のプログラムと競合すること無く各ストリームオブジェクト内に `void*` 型の私用記憶域を確保することが可能となる。 - 本関数で取得した `void*` への参照は、本オブジェクトの他の操作によって無効になる可能性がある。 しかし、その場合でも引数 `idx` で指定した記憶域の内容は依然として有効である。 - 本関数で取得した `void*` 型の記憶域の内容は、[`basic_ios`](../basic_ios.md)`::`[`copyfmt`](../basic_ios/copyfmt.md) でコピーされる。 @@ -129,10 +132,14 @@ int main() (コールバックは例外を送出してはいけない。[`register_callback`](register_callback.md) の要件を参照) -## 参照 +## 関連項目 - [`xalloc`](xalloc.md) - [`iword`](iword.md) - [`basic_ios`](../basic_ios.md)`::`[`copyfmt`](../basic_ios/copyfmt.md) - [`register_callback`](register_callback.md) - [`event_callback`](type-event_callback.md) - [`event`](type-event.md) + +## 参照 +- [LWG Issue 3083. What should `ios::iword(-1)` do?](https://cplusplus.github.io/LWG/issue3083) + - C++20で、引数には[`xalloc`](xalloc.md)で取得した値を渡すことが事前条件として明確化された(それ以外の値を渡した場合の動作は未規定) diff --git a/reference/istream/basic_istream/gcount.md b/reference/istream/basic_istream/gcount.md index 0670686a2a..b1d0d0c617 100644 --- a/reference/istream/basic_istream/gcount.md +++ b/reference/istream/basic_istream/gcount.md @@ -14,6 +14,11 @@ streamsize gcount(); ## 戻り値 最後に実行した非書式化関数での入力文字数。 +入力文字数が[`streamsize`](/reference/ios/type-streamsize.md)で表現できる範囲を超える場合の扱いは、バージョンによって異なる。 + +- C++03 : 規定されていない +- C++23 : その文字数が[`numeric_limits`](/reference/limits/numeric_limits.md)`<`[`streamsize`](/reference/ios/type-streamsize.md)`>::`[`max()`](/reference/limits/numeric_limits/max.md)を超える場合は、[`numeric_limits`](/reference/limits/numeric_limits.md)`<`[`streamsize`](/reference/ios/type-streamsize.md)`>::`[`max()`](/reference/limits/numeric_limits/max.md)を返す + ## 例 [`read`メンバ関数](read.md)の例を参照。 @@ -22,3 +27,5 @@ streamsize gcount(); - C++98 ## 参照 +- [LWG Issue 3464. `istream::gcount()` can overflow](https://cplusplus.github.io/LWG/issue3464) + - C++23で、抽出文字数が[`streamsize`](/reference/ios/type-streamsize.md)で表現できない場合に[`numeric_limits`](/reference/limits/numeric_limits.md)`::max()`を返すことが規定された diff --git a/reference/istream/basic_istream/putback.md b/reference/istream/basic_istream/putback.md index c062cf2908..8fc949bb58 100644 --- a/reference/istream/basic_istream/putback.md +++ b/reference/istream/basic_istream/putback.md @@ -99,3 +99,5 @@ basic_istream& putback(char_type c) { - [`basic_streambuf::sputbackc`](../../streambuf/basic_streambuf/sputbackc.md) - [P1264R2 Revising the wording of stream input operations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1264r2.pdf) - C++23でローカルエラー状態の概念が導入され、入力関数のエラー処理セマンティクスが明確化された +- [LWG Issue 2243. `istream::putback` problem](https://cplusplus.github.io/LWG/issue2243) + - C++20で、効果の記述にあった編集上の誤り(`sputbackc`の呼び出しに戻す文字を渡していなかった等)が修正された diff --git a/reference/istream/basic_istream/unget.md b/reference/istream/basic_istream/unget.md index 11b7de7004..0971841c67 100644 --- a/reference/istream/basic_istream/unget.md +++ b/reference/istream/basic_istream/unget.md @@ -110,3 +110,5 @@ basic_istream& unget() { - [`basic_streambuf::sungetc`](../../streambuf/basic_streambuf/sungetc.md) - [P1264R2 Revising the wording of stream input operations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1264r2.pdf) - C++23でローカルエラー状態の概念が導入され、入力関数のエラー処理セマンティクスが明確化された +- [LWG Issue 2243. `istream::putback` problem](https://cplusplus.github.io/LWG/issue2243) + - C++20で、[`putback`](putback.md)の効果の記述にあった編集上の誤りが修正された diff --git a/reference/iterator/disable_sized_sentinel_for.md b/reference/iterator/disable_sized_sentinel_for.md index ed57a4d795..11c4c3bfd0 100644 --- a/reference/iterator/disable_sized_sentinel_for.md +++ b/reference/iterator/disable_sized_sentinel_for.md @@ -62,3 +62,5 @@ namespace std { - [microsoft/STL P1871R1 disable_sized_sentinel_for #607 - Github](https://github.com/microsoft/STL/pull/607/files#r392700693) - [LWG Issue 3736. `move_iterator` missing `disable_sized_sentinel_for` specialization](https://cplusplus.github.io/LWG/issue3736) - C++23で、`move_iterator`に対する`disable_sized_sentinel_for`の特殊化が追加され、`move_iterator`が意味論的に`sized_sentinel_for`を満たさない場合に誤ってそれを満たすと判定される問題が解消された +- [LWG Issue 3183. Normative permission to specialize Ranges variable templates](https://cplusplus.github.io/LWG/issue3183) + - C++20で、プログラム定義型に対してこの変数テンプレートを特殊化してよいという規範的な許可が明記された diff --git a/reference/iterator/iterator_traits.md b/reference/iterator/iterator_traits.md index 2f1dafd0fd..591f82e0e6 100644 --- a/reference/iterator/iterator_traits.md +++ b/reference/iterator/iterator_traits.md @@ -144,11 +144,11 @@ namespace std { ```cpp template concept cpp17-iterator = - copyable && requires(I i) { + requires(I i) { { *i } -> can-reference; { ++i } -> same_as; { *i++ } -> can-reference; - }; + } && copyable; template concept cpp17-input-iterator = @@ -255,3 +255,5 @@ int main() - [LWG 2952. `iterator_traits` should work for pointers to cv `T`](https://wg21.cmeerw.net/lwg/issue2952) - C++17から、`const T*`の部分特殊化が、`T*`の部分特殊化に統合され、`volatile`付きのポインタもこのクラスで扱えるようになった - [P0896R4 The One Ranges Proposal (was Merging the Ranges TS)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0896r4.pdf) +- [LWG Issue 3420. cpp17-iterator should check that the type looks like an iterator first](https://cplusplus.github.io/LWG/issue3420) + - C++23で、説明専用コンセプト`cpp17-iterator`の定義で`copyable`の位置が`requires`式の後ろに移動され、イテレータらしい形を先に確認するようになった(満たす型集合は不変) diff --git a/reference/iterator/ranges_advance.md b/reference/iterator/ranges_advance.md index 7ebbfd3830..27a4239edf 100644 --- a/reference/iterator/ranges_advance.md +++ b/reference/iterator/ranges_advance.md @@ -33,7 +33,7 @@ namespace std::ranges { ## 事前条件 - (1) : `I`が[`bidirectional_iterator`](bidirectional_iterator.md)のモデルとならない場合、`n`は負数ではない -- (2) : `[i, bound)`は有効なイテレータ範囲である +- (2) : [`assignable_from`](/reference/concepts/assignable_from.md)``または[`sized_sentinel_for`](sized_sentinel_for.md)``のいずれもモデルとならない場合、`[i, bound)`は有効なイテレータ範囲である - (3) : 次のいずれか - `n > 0` : `[i, bound)`は有効なイテレータ範囲である - `n == 0` : `[i, bound)`もしくは`[bound, i)`は有効なイテレータ範囲である @@ -131,3 +131,5 @@ diff : 2 ## 参照 - [P0896R4 The One Ranges Proposal (was Merging the Ranges TS)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0896r4.pdf) +- [LWG Issue 3306. `ranges::advance` violates its preconditions](https://cplusplus.github.io/LWG/issue3306) + - C++23で、番兵を取る(2)の事前条件が緩和され、`assignable_from`または`sized_sentinel_for`のいずれかがモデルとなる場合は`[i, bound)`が有効な範囲であることを要求しないようになった diff --git a/reference/memory/allocate_shared.md b/reference/memory/allocate_shared.md index 3606ed50f1..227cb1387b 100644 --- a/reference/memory/allocate_shared.md +++ b/reference/memory/allocate_shared.md @@ -158,5 +158,11 @@ int main() { ## 参照 - [P0674R1 Extending `make_shared` to support arrays](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0674r1.html) - [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) +- [LWG Issue 3005. Destruction order of arrays by `make_shared`/`allocate_shared` only recommended?](https://cplusplus.github.io/LWG/issue3005) + - C++20で、配列要素の破棄順が非規範的な推奨から規範的要件に格上げされ、元の構築順の逆順で破棄されることが明確化された +- [LWG Issue 3007. `allocate_shared` should rebind allocator to cv-unqualified `value_type` for construction](https://cplusplus.github.io/LWG/issue3007) + - C++20で、オブジェクト構築のためにアロケータをリバウンドする先の`value_type`が、`U`ではなく[`remove_cv_t`](/reference/type_traits/remove_cv.md)``(CV修飾を除去した型)に修正された +- [LWG Issue 3008. `make_shared` (sub)object destruction semantics are not specified](https://cplusplus.github.io/LWG/issue3008) + - C++20で、生成した(サブ)オブジェクトの破棄方法(`allocate_shared`は`allocator_traits::destroy`による破棄)が明示的に規定された - [LWG Issue 4451. `make_shared` should not refer to a type `U[N]` for runtime N](https://cplusplus.github.io/LWG/issue4451) - C++26で、`N`が実行時の値である配列版において、結果を「`U[N]`型のオブジェクト」ではなく「[`remove_extent_t`](../type_traits/remove_extent.md)``型の`N`要素の配列」と表現するよう文言が修正された(実行時サイズの`U[N]`は妥当な型ではないため) \ No newline at end of file diff --git a/reference/memory/allocator.md b/reference/memory/allocator.md index b212595769..a3c9b76b48 100644 --- a/reference/memory/allocator.md +++ b/reference/memory/allocator.md @@ -64,7 +64,7 @@ C++11から: | `reference` | 要素の参照型 `T&` | C++17から非推奨
C++20で削除 | | `const_reference` | 読み取り専用の要素の参照型 `const T&` | C++17から非推奨
C++20で削除 | | `rebind` | 型`U`を確保するように再束縛する | C++17から非推奨
C++20で削除 | -| `is_always_equal` | 同じ型のアロケータオブジェクトが2つある場合、それらが常に同値であるか。[`true_type`](/reference/type_traits/true_type.md) | C++17
C++20で非推奨
C++26で削除 | +| `is_always_equal` | 同じ型のアロケータオブジェクトが2つある場合、それらが常に同値であるか。[`true_type`](/reference/type_traits/true_type.md) | C++17
C++23で非推奨
C++26で削除 | ## 非メンバ関数 @@ -87,7 +87,7 @@ C++11から: - なお、プライマリテンプレートからインスタンス化されるようになっても`allocate`/`deallocate`メンバは内部で`sizeof(void)`を要求するため引き続き使用不可能であり、`std::allocator`の使用用途としては従来と同じく再束縛を目的とすることになる(上述のように[`std::allocator_traits`](allocator_traits.md)の代替機能を用いて`typename` [`std::allocator_traits`](allocator_traits.md)`>::template rebind_alloc`のようにする)。 - メンバ型の`size_type`と`difference_type`は、C++17で非推奨となったがC++20で非推奨が取り消された。 -- メンバ型の`is_always_equal`は、このクラスを継承したメモリアロケータが`is_always_equal`の値を引き継いでしまうという点で問題があったため、C++20で非推奨となり、C++26で削除された。 +- メンバ型の`is_always_equal`は、このクラスを継承したメモリアロケータが`is_always_equal`の値を引き継いでしまうという点で問題があったため、C++23で非推奨となり、C++26で削除された。 - 代わりに[`std::allocator_traits`](allocator_traits.md)クラスの`is_always_equal`メンバ型を使用すること。 @@ -144,6 +144,6 @@ int main(int argc, char** argv) { - [P0619R4 Reviewing deprecated facilities of C++17 for C++20](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0619r4.html) - [N4258 Cleaning-up noexcept in the Library, Rev 3](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258.pdf) - [LWG Issue 3170. `is_always_equal` added to `std::allocator` makes the standard library treat derived types as always equal](https://cplusplus.github.io/LWG/issue3170) - - C++20で`is_always_equal`メンバ型が非推奨化された + - C++23で`is_always_equal`メンバ型が非推奨化された - [P2868R3 Remove Deprecated `std::allocator` Typedef From C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2868r3.pdf) - C++26で`is_always_equal`メンバ型が削除された diff --git a/reference/memory/allocator/allocate.md b/reference/memory/allocator/allocate.md index 846b90a3c0..1d9feab6d9 100644 --- a/reference/memory/allocator/allocate.md +++ b/reference/memory/allocator/allocate.md @@ -27,6 +27,11 @@ pointer allocate(size_type n, ## 例外 ストレージからのメモリ確保に失敗した場合、[`bad_alloc`](/reference/new/bad_alloc.md)例外を送出する。 +要求サイズが乗算オーバーフローを起こす(`SIZE_MAX / sizeof(T) < n`である)場合の扱いは、バージョンによって異なる。 + +- C++03 : この場合の例外は規定されていない +- C++20 : [`bad_array_new_length`](/reference/new/bad_array_new_length.md)例外を送出する + ## 備考 コンテナのメンバ関数でこの関数を使用する場合には、隣接要素のアドレスをヒントとして渡すのが適している。 @@ -73,3 +78,5 @@ int main() - C++20で`constexpr`が付加された - [P2422R1 Remove `nodiscard` annotations from the standard library specification](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2422r1.html) - C++26で`[[nodiscard]]`指定が削除された +- [LWG Issue 3190. `std::allocator::allocate` sometimes returns too little storage](https://cplusplus.github.io/LWG/issue3190) + - C++20で、要求サイズが乗算オーバーフローを起こす(`SIZE_MAX / sizeof(T) < n`)場合に[`bad_array_new_length`](/reference/new/bad_array_new_length.md)を送出することが規定された diff --git a/reference/memory/make_obj_using_allocator.md b/reference/memory/make_obj_using_allocator.md index 545cac027c..cf92a5383f 100644 --- a/reference/memory/make_obj_using_allocator.md +++ b/reference/memory/make_obj_using_allocator.md @@ -6,7 +6,7 @@ ```cpp template - T make_obj_using_allocator(const Alloc& alloc, Args&&... args); + constexpr T make_obj_using_allocator(const Alloc& alloc, Args&&... args); ``` ## 概要 @@ -108,3 +108,5 @@ int main() ## 参照 - [P0591R4 Utility functions to implement uses-allocator construction](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0591r4.pdf) +- [LWG Issue 3185. Uses-allocator construction functions missing `constexpr` and `noexcept`](https://cplusplus.github.io/LWG/issue3185) + - C++20で、この関数に`constexpr`が付加された diff --git a/reference/memory/make_shared.md b/reference/memory/make_shared.md index f1375a98a8..1e8afcc179 100644 --- a/reference/memory/make_shared.md +++ b/reference/memory/make_shared.md @@ -145,5 +145,9 @@ int main() { - [std::make_shared から private コンストラクタを呼び出す - 野良C++erの雑記帳](http://d.hatena.ne.jp/gintenlabo/20131211/1386771626) - [P0674R1 Extending `make_shared` to support arrays](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0674r1.html) - [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) +- [LWG Issue 3005. Destruction order of arrays by `make_shared`/`allocate_shared` only recommended?](https://cplusplus.github.io/LWG/issue3005) + - C++20で、配列要素の破棄順が非規範的な推奨から規範的要件に格上げされ、元の構築順の逆順で破棄されることが明確化された +- [LWG Issue 3008. `make_shared` (sub)object destruction semantics are not specified](https://cplusplus.github.io/LWG/issue3008) + - C++20で、生成した(サブ)オブジェクトの破棄方法(`make_shared`は式`pv->~U()`による破棄)が明示的に規定された - [LWG Issue 4451. `make_shared` should not refer to a type `U[N]` for runtime N](https://cplusplus.github.io/LWG/issue4451) - C++26で、`N`が実行時の値である配列版において、結果を「`U[N]`型のオブジェクト」ではなく「[`remove_extent_t`](../type_traits/remove_extent.md)``型の`N`要素の配列」と表現するよう文言が修正された(実行時サイズの`U[N]`は妥当な型ではないため) \ No newline at end of file diff --git a/reference/memory/shared_ptr/op_compare_3way.md b/reference/memory/shared_ptr/op_compare_3way.md index a6358bb539..3c8ad493b6 100644 --- a/reference/memory/shared_ptr/op_compare_3way.md +++ b/reference/memory/shared_ptr/op_compare_3way.md @@ -40,7 +40,7 @@ namespace std { - (2) : ```cpp - return compare_three_way()(a.get(), nullptr); + return compare_three_way()(a.get(), static_cast::element_type*>(nullptr)); ``` * compare_three_way[link /reference/compare/compare_three_way.md] * get()[link get.md] @@ -98,4 +98,6 @@ p3 is nullptr ## 参照 - [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html) - C++20での三方比較演算子の追加と、関連する演算子の自動導出 +- [LWG Issue 3427. `operator<=>(const shared_ptr&, nullptr_t)` definition ill-formed](https://cplusplus.github.io/LWG/issue3427) + - C++23で、`nullptr`との三方比較(2)の戻り値定義が、`compare_three_way`がポインタ型を推論できるよう`static_cast`でポインタ型に変換する形に修正された - [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) \ No newline at end of file diff --git a/reference/memory/uninitialized_copy.md b/reference/memory/uninitialized_copy.md index d8fab7c639..a5e5d0f908 100644 --- a/reference/memory/uninitialized_copy.md +++ b/reference/memory/uninitialized_copy.md @@ -113,5 +113,7 @@ int main() ## 参照 - [LWG Issue 2433 `uninitialized_copy()`/etc. should tolerate overloaded `operator&`](https://wg21.cmeerw.net/lwg/issue2433) +- [LWG Issue 3054. `uninitialized_copy` appears to not be able to meet its exception-safety guarantee](https://cplusplus.github.io/LWG/issue3054) + - C++20で、例外送出時に「効果なし」とする達成不能な保証が撤廃され、構築済みのオブジェクトを未規定の順序で破棄してから例外を伝播すると明確化された - [P3508R0 Wording for "constexpr for specialized memory algorithms"](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3508r0.html) - C++26から`constexpr`がついた diff --git a/reference/memory/uninitialized_copy_n.md b/reference/memory/uninitialized_copy_n.md index 7904726a94..d1ebfa7de6 100644 --- a/reference/memory/uninitialized_copy_n.md +++ b/reference/memory/uninitialized_copy_n.md @@ -131,5 +131,7 @@ int main() - [N2569 More STL algorithms](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2569.pdf) - [N2666 More STL algorithms (revision 2)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2666.pdf) - [LWG Issue 2433 `uninitialized_copy()`/etc. should tolerate overloaded `operator&`](https://wg21.cmeerw.net/lwg/issue2433) +- [LWG Issue 3054. `uninitialized_copy` appears to not be able to meet its exception-safety guarantee](https://cplusplus.github.io/LWG/issue3054) + - C++20で、例外送出時に「効果なし」とする達成不能な保証が撤廃され、構築済みのオブジェクトを未規定の順序で破棄してから例外を伝播すると明確化された - [P3508R0 Wording for "constexpr for specialized memory algorithms"](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3508r0.html) - C++26から`constexpr`がついた diff --git a/reference/memory/uninitialized_move.md b/reference/memory/uninitialized_move.md index 963f9fe538..dad5799b87 100644 --- a/reference/memory/uninitialized_move.md +++ b/reference/memory/uninitialized_move.md @@ -55,6 +55,8 @@ for (; first != last; ++result, ++first) 呼び出すコンストラクタなどから例外が送出された場合、その例外がこの関数の外側に伝播される前に、その時点で構築済のオブジェクトは全て未規定の順序で破棄される。すなわち、例外が送出された場合は初期化対象領域は未初期化のままとなる。 +ただし、ムーブ元の範囲`[first, last)`のオブジェクトの一部は、すでにムーブされた結果として有効だが未規定の状態になっていることがある。 + ### 例 ```cpp example #include @@ -120,6 +122,8 @@ int main() - [P0040R3 Extending memory management tools](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0040r3.html) - [P3508R0 Wording for "constexpr for specialized memory algorithms"](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3508r0.html) - C++26から`constexpr`がついた +- [LWG Issue 3054. `uninitialized_copy` appears to not be able to meet its exception-safety guarantee](https://cplusplus.github.io/LWG/issue3054) + - C++20で、例外送出時に「効果なし」とする達成不能な保証が撤廃され、構築済みのオブジェクトを未規定の順序で破棄してから例外を伝播すると明確化された - [LWG Issue 3918. `std::uninitialized_move`/`_n` and guaranteed copy elision](https://cplusplus.github.io/LWG/issue3918) - C++26で、要素の構築に説明専用ヘルパ`deref-move`を用いるようになり、`*first`がprvalueを返すイテレータに対してコピーの省略が保証されるようになった - [LWG Issue 4452. Make _deref-move_ constexpr](https://cplusplus.github.io/LWG/issue4452) diff --git a/reference/memory/uninitialized_move_n.md b/reference/memory/uninitialized_move_n.md index b7b136d5f6..1962f416f7 100644 --- a/reference/memory/uninitialized_move_n.md +++ b/reference/memory/uninitialized_move_n.md @@ -55,6 +55,8 @@ for (; n > 0; ++result, (void)++first, --n) 呼び出すコンストラクタなどから例外が送出された場合、その例外がこの関数の外側に伝播される前に、その時点で構築済のオブジェクトは全て未規定の順序で破棄される。すなわち、例外が送出された場合は初期化対象領域は未初期化のままとなる。 +ただし、ムーブ元の範囲`[first, first + n)`のオブジェクトの一部は、すでにムーブされた結果として有効だが未規定の状態になっていることがある。 + ### 例 ```cpp example #include @@ -121,6 +123,8 @@ int main() - [P0040R3 Extending memory management tools](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0040r3.html) - [P3508R0 Wording for "constexpr for specialized memory algorithms"](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3508r0.html) - C++26から`constexpr`がついた +- [LWG Issue 3054. `uninitialized_copy` appears to not be able to meet its exception-safety guarantee](https://cplusplus.github.io/LWG/issue3054) + - C++20で、例外送出時に「効果なし」とする達成不能な保証が撤廃され、構築済みのオブジェクトを未規定の順序で破棄してから例外を伝播すると明確化された - [LWG Issue 3918. `std::uninitialized_move`/`_n` and guaranteed copy elision](https://cplusplus.github.io/LWG/issue3918) - C++26で、要素の構築に説明専用ヘルパ`deref-move`を用いるようになり、`*first`がprvalueを返すイテレータに対してコピーの省略が保証されるようになった - [LWG Issue 4452. Make _deref-move_ constexpr](https://cplusplus.github.io/LWG/issue4452) diff --git a/reference/memory/unique_ptr/op_assign.md b/reference/memory/unique_ptr/op_assign.md index 89fe13b097..a929a807a2 100644 --- a/reference/memory/unique_ptr/op_assign.md +++ b/reference/memory/unique_ptr/op_assign.md @@ -28,13 +28,14 @@ unique_ptr& operator=(const unique_ptr&) = delete; // (4) C++11 - (4) : コピー代入禁止。 -## 要件 -- (1) : デリータの型`D`が、例外を投げずにムーブ構築可能であること。 -- (2) 単一オブジェクト : 以下の条件を満たさない場合、この関数はオーバーロード解決の候補から外れる: +## テンプレートパラメータ制約 +- (1) : + - C++20 : [`is_move_assignable_v`](/reference/type_traits/is_move_assignable.md)` == true`であること。 +- (2) 単一オブジェクト : 以下を全て満たすこと: - `unique_ptr::pointer`が、`pointer`に暗黙変換可能な型であること。 - `U`が配列型ではないこと。 - [`is_assignable_v`](/reference/type_traits/is_assignable.md)` == true`であること。 -- (2) 配列 : 以下の条件を満たさない場合、この関数はオーバーロード解決の候補から外れる: +- (2) 配列 : 以下を全て満たすこと: - `U`は配列型であること。 - `*this`の型`UP`について、`UP::pointer`と`UP::element_type*`が同じ型であること。 - `u`の型`UP`について、`UP::pointer`と`UP::element_type*`が同じ型であること。 @@ -42,6 +43,10 @@ unique_ptr& operator=(const unique_ptr&) = delete; // (4) C++11 - [`is_assignable_v`](/reference/type_traits/is_assignable.md)` == true`であること。 +## 要件 +- (1) : デリータの型`D`が、例外を投げずにムーブ構築可能であること。 + + ## 効果 - (1), (2) : @@ -57,6 +62,10 @@ d_ = std::forward(u.get_deleter()); - (3) : [`reset()`](reset.md) +## 事後条件 +- (1), (2) : [`addressof`](/reference/memory/addressof.md)`(u) != this`である場合、`u.`[`get()`](get.md)` == nullptr`となる。そうでない(自己ムーブ代入の)場合、`u.`[`get()`](get.md)`は変更されない。 + + ## 戻り値 `*this` @@ -116,4 +125,8 @@ int main() - [LWG 2246. `unique_ptr` assignment effects w.r.t. deleter](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2246) - [LWG 2228: Missing SFINAE rule in unique_ptr templated assignment](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4366) - (2)のSFINAEルール不足の欠陥修正の提案文書 +- [LWG Issue 2899. `is_(nothrow_)move_constructible` and `tuple`, `optional` and `unique_ptr`](https://cplusplus.github.io/LWG/issue2899) + - C++20で、ムーブ代入演算子(1)が、デリータ型`D`がムーブ代入可能でない場合はオーバーロード解決に参加しないよう制約化された - [P2273R3 Making `std::unique_ptr` constexpr](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2273r3.pdf) +- [LWG Issue 3455. Incorrect Postconditions on `unique_ptr` move assignment](https://cplusplus.github.io/LWG/issue3455) + - C++23で、ムーブ代入の事後条件が自己ムーブ代入を考慮するよう修正された(`this != addressof(u)`のときのみ`u.get() == nullptr`となる)。これは誤っていた事後条件の文言を修正したものであり、効果`reset(u.release())`による実際の挙動(自己ムーブ代入では`u`が変化しない)はC++11から一貫して同じであるため、本文の事後条件はバージョンによらずこの記述となる diff --git a/reference/memory/unique_ptr/op_constructor.md b/reference/memory/unique_ptr/op_constructor.md index 3f54323b22..83a5dc60c6 100644 --- a/reference/memory/unique_ptr/op_constructor.md +++ b/reference/memory/unique_ptr/op_constructor.md @@ -75,6 +75,8 @@ unique_ptr(const unique_ptr&) = delete; // (9) 単一オブジェクト、 - [`is_pointer_v`](/reference/type_traits/is_pointer.md) `== true`である(デリータがポインタである) - [`is_default_constructible_v`](/reference/type_traits/is_default_constructible.md) `== false`である(デリータがデフォルト構築できない) - (3), (4) : [`is_constructible_v`](/reference/type_traits/is_constructible.md) `== true`の(`d`からコピー/ムーブ構築可能な)場合にのみオーバーロード解決に参加する。 +- (5) : + - C++20 : [`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md) `== true`の場合にのみオーバーロード解決に参加する。 - (3), (4), (6) : [クラステンプレートの実引数推定](/lang/cpp17/type_deduction_for_class_templates.md)によってこれらのコンストラクタが選択される場合、コンパイルエラーとなる。 ### C++17 配列版 @@ -208,6 +210,8 @@ int main() - [LWG Issue 2520 : N4089 broke initializing `unique_ptr` from a nullptr](https://wg21.cmeerw.net/lwg/issue2520) - [LWG Issue 2801. Default-constructibility of `unique_ptr`](https://wg21.cmeerw.net/lwg/issue2948) - [LWG Issue 2905. `is_constructible_v, P, D const &>` should be false when D is not copy constructible](https://wg21.cmeerw.net/lwg/issue2905) +- [LWG Issue 2899. `is_(nothrow_)move_constructible` and `tuple`, `optional` and `unique_ptr`](https://cplusplus.github.io/LWG/issue2899) + - C++20で、ムーブコンストラクタ(5)が、デリータ型`D`がムーブ構築可能でない場合はオーバーロード解決に参加しないよう制約化され、`is_move_constructible>`が正しく判定されるようになった - [LWG Issue 3632. `unique_ptr` "_Mandates_: This constructor is not selected by class template argument deduction"](https://cplusplus.github.io/LWG/issue3632) - C++23で、クラステンプレート実引数推論(CTAD)による選択を防ぐ仕様が、Mandates指定から引数型を`type_identity_t`とする方式へ書き換えられた(観測可能な振る舞いは変わらない) - [P2273R3 Making `std::unique_ptr` constexpr](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2273r3.pdf) diff --git a/reference/memory/uses_allocator_construction_args.md b/reference/memory/uses_allocator_construction_args.md index 1a8a558cfc..9c1d152ff5 100644 --- a/reference/memory/uses_allocator_construction_args.md +++ b/reference/memory/uses_allocator_construction_args.md @@ -9,7 +9,7 @@ template constexpr auto uses_allocator_construction_args( const Alloc& alloc, - Args&&... args) -> see below; // (1) C++20 + Args&&... args) noexcept -> see below; // (1) C++20 template constexpr auto @@ -17,19 +17,19 @@ constexpr auto const Alloc& alloc, piecewise_construct_t, Tuple1&& x, - Tuple2&& y) -> see below; // (2) C++20 + Tuple2&& y) noexcept -> see below; // (2) C++20 template constexpr auto uses_allocator_construction_args( - const Alloc& alloc) -> see below; // (3) C++20 + const Alloc& alloc) noexcept -> see below; // (3) C++20 template constexpr auto uses_allocator_construction_args( const Alloc& alloc, U&& u, - V&& v) -> see below; // (4) C++20 + V&& v) noexcept -> see below; // (4) C++20 template constexpr auto @@ -41,13 +41,13 @@ template constexpr auto uses_allocator_construction_args( const Alloc& alloc, - const pair& pr) -> see below; // (6) C++20 + const pair& pr) noexcept -> see below; // (6) C++20 template constexpr auto uses_allocator_construction_args( const Alloc& alloc, - pair&& pr) -> see below; // (7) C++20 + pair&& pr) noexcept -> see below; // (7) C++20 template constexpr auto @@ -95,7 +95,7 @@ forward_as_tuple(std::forward(args)...) * forward_as_tuple[link ../tuple/forward_as_tuple.md] * forward[link ../utility/forward.md] - - 上記以外で、もし [`uses_allocator_v`](uses_allocator.md)`` が `true` で、かつ、[`is_constructible_v`](../type_traits/is_constructible.md)`` が `true` の場合、 + - 上記以外で、もし [`uses_allocator_v`](uses_allocator.md)`` が `true` で、かつ、[`is_constructible_v`](../type_traits/is_constructible.md)`` が `true` の場合、 ```cpp tuple( @@ -105,7 +105,7 @@ tuple( * allocator_arg[link allocator_arg_t.md] * forward[link ../utility/forward.md] - - 上記以外で、もし [`uses_allocator_v`](uses_allocator.md)`` が `true` で、かつ、[`is_constructible_v`](../type_traits/is_constructible.md)`` が `true` の場合、 + - 上記以外で、もし [`uses_allocator_v`](uses_allocator.md)`` が `true` で、かつ、[`is_constructible_v`](../type_traits/is_constructible.md)`` が `true` の場合、 ```cpp forward_as_tuple(std::forward(args)..., alloc) @@ -322,6 +322,10 @@ tuple(piecewise_construct_t, tuple(allocator_arg_t, MyAlloc, 3, ), tuple(4, MyAl ## 参照 - [P0591R4 Utility functions to implement uses-allocator construction](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0591r4.pdf) - [P2321R2 zip](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2321r2.html) +- [LWG Issue 3185. Uses-allocator construction functions missing `constexpr` and `noexcept`](https://cplusplus.github.io/LWG/issue3185) + - C++20で、C++20時点の各オーバーロードに`noexcept`が付加された([`make_obj_using_allocator`](make_obj_using_allocator.md)には`constexpr`が付加された) +- [LWG Issue 3187. P0591R4 reverted DR 2586 fixes to `scoped_allocator_adaptor::construct()`](https://cplusplus.github.io/LWG/issue3187) + - C++20で、`is_constructible_v`による構築可能性の検査が、返却するタプルと一致するよう`Alloc`から`const Alloc&`に修正された - [LWG Issue 3525. `uses_allocator_construction_args` fails to handle types convertible to `pair`](https://cplusplus.github.io/LWG/issue3525) - C++23で、`T`が`pair`特殊化かつ引数`u`が`pair`に変換できない場合に対応する(10)のオーバーロードが追加された - [LWG Issue 3821. `uses_allocator_construction_args` should have overload for `pair-like`](https://cplusplus.github.io/LWG/issue3821) diff --git a/reference/memory/weak_ptr/op_assign.md b/reference/memory/weak_ptr/op_assign.md index 0b191cb662..09528add8c 100644 --- a/reference/memory/weak_ptr/op_assign.md +++ b/reference/memory/weak_ptr/op_assign.md @@ -163,4 +163,6 @@ int main() ## 参照 - [LWG Issue 2315. `weak_ptr` should be movable](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2315) -- [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) \ No newline at end of file +- [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) +- [LWG Issue 3195. What is the stored pointer value of an empty `weak_ptr`?](https://cplusplus.github.io/LWG/issue3195) + - C++23で、空の`weak_ptr`がヌルポインタ値を格納することが明確化された diff --git a/reference/memory/weak_ptr/op_constructor.md b/reference/memory/weak_ptr/op_constructor.md index 54bed4d4a9..d0795c2dc1 100644 --- a/reference/memory/weak_ptr/op_constructor.md +++ b/reference/memory/weak_ptr/op_constructor.md @@ -52,8 +52,8 @@ weak_ptr(weak_ptr&& r) noexcept; // (6) C++26 ## 効果 -- (1) : 監視対象を持たない、空の`weak_ptr`オブジェクトを構築する。 -- (2), (3) : `r`が空である場合、空の`weak_ptr`オブジェクトを構築する。そうでなければ、`r`の監視対象を`*this`にコピーする。 +- (1) : 監視対象を持たない、空の`weak_ptr`オブジェクトを構築する。この空の`weak_ptr`は、ヌルポインタ値を格納する。 +- (2), (3) : `r`が空である場合、空の`weak_ptr`オブジェクト(ヌルポインタ値を格納する)を構築する。そうでなければ、`r`の監視対象を`*this`にコピーする。 - (4) : `r`を`*this`の監視対象とする。 - (5), (6) : `r`の監視対象を`*this`に移動する。 @@ -61,7 +61,11 @@ weak_ptr(weak_ptr&& r) noexcept; // (6) C++26 ## 事後条件 - (1) : [`use_count()`](use_count.md) `== 0` - (2), (3), (4) : [`use_count()`](use_count.md) `==` `r.`[`use_count()`](use_count.md) -- (5), (6) : `r.`[`use_count()`](use_count.md) `== 0` +- (5), (6) : `r`は空になり、ヌルポインタ値を格納し、`r.`[`use_count()`](use_count.md) `== 0`となる。 + + +## 備考 +- ここでいう「格納するポインタ値」とは、`weak_ptr`が内部的に保持するポインタであり、[`lock()`](lock.md)で得られる[`shared_ptr`](../shared_ptr.md)の格納ポインタ([`get()`](../shared_ptr/get.md)が返す値)の元になるものである。空の`weak_ptr`がヌルポインタ値を格納することは、C++23で明確化された(それ以前は規定されていなかったが、`weak_ptr`自身にこの値を直接取得する手段はないため、観測可能な影響はない)。 ## 例 @@ -155,4 +159,6 @@ int main() ## 参照 - [LWG Issue 2315. `weak_ptr` should be movable](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2315) - [P0414R1 Merging `shared_ptr` changes from Library Fundamentals to C++17](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0414r1.html) -- [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) \ No newline at end of file +- [P3037R6 `constexpr std::shared_ptr` and friends](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf) +- [LWG Issue 3195. What is the stored pointer value of an empty `weak_ptr`?](https://cplusplus.github.io/LWG/issue3195) + - C++23で、空の`weak_ptr`がヌルポインタ値を格納することが明確化された diff --git a/reference/memory_resource/monotonic_buffer_resource.md b/reference/memory_resource/monotonic_buffer_resource.md index ad76849480..5207b440fb 100644 --- a/reference/memory_resource/monotonic_buffer_resource.md +++ b/reference/memory_resource/monotonic_buffer_resource.md @@ -86,3 +86,5 @@ namespace std::pmr { - [P0220R1 Adopt Library Fundamentals V1 TS Components for C++17 (R1)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html) - [P0337r0 | Delete operator= for polymorphic_allocator](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0337r0.html) - [Working Draft, C++ Extensions for Library Fundamentals, Version 2](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4562.html#memory.resource.synop) +- [LWG Issue 3143. `monotonic_buffer_resource` growth policy is unclear](https://cplusplus.github.io/LWG/issue3143) + - C++23で、クラスの性質の記述が整理・明確化された diff --git a/reference/memory_resource/monotonic_buffer_resource/release.md b/reference/memory_resource/monotonic_buffer_resource/release.md index 9398837c41..958d497e34 100644 --- a/reference/memory_resource/monotonic_buffer_resource/release.md +++ b/reference/memory_resource/monotonic_buffer_resource/release.md @@ -17,8 +17,10 @@ void release(); 必要に応じて[`this->upstream_resource()`](upstream_resource.md)[`->deallocate()`](/reference/memory_resource/memory_resource/deallocate.md)を呼び出し上流メモリリソースから割り当てた全てのメモリを解放する。 `deallocate()`によって割り当て解除されていないメモリがあったとしても、全てのメモリが解放される。 -コンストラクタから設定された初期メモリ領域の解放は行われない。 - +解放後の状態は、バージョンによって異なる。 + +- C++17 : コンストラクタで設定された初期メモリ領域が再び割り当てに利用可能になるかどうかは規定されていない +- C++23 : `*this`を構築時の初期状態にリセットする。これにより、コンストラクタで設定された初期メモリ領域が再び割り当てに利用可能になる ## 例 ```cpp example @@ -63,3 +65,5 @@ int main() { - [P0220R1 Adopt Library Fundamentals V1 TS Components for C++17 (R1)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html) - [P0337r0 | Delete operator= for polymorphic_allocator](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0337r0.html) - [Working Draft, C++ Extensions for Library Fundamentals, Version 2](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4562.html#memory.resource.synop) +- [LWG Issue 3120. Unclear behavior of `monotonic_buffer_resource::release()`](https://cplusplus.github.io/LWG/issue3120) + - C++23で、`release()`の効果が、`*this`を構築時の初期状態にリセットする(初期バッファが再び利用可能になる)ことと明確化された diff --git a/reference/mutex/scoped_lock.md b/reference/mutex/scoped_lock.md index 6a2d9e0d69..78b3a6dd4b 100644 --- a/reference/mutex/scoped_lock.md +++ b/reference/mutex/scoped_lock.md @@ -97,3 +97,5 @@ int main() ## 参照 - [P0156R2 Variadic `lock_guard` (Rev. 5)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0156r2.html) - [P0739R0 Some improvements to class template argument deduction integration into the standard library](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0739r0.html) +- [LWG Issue 2731. Existence of `lock_guard::mutex_type` typedef unclear](https://cplusplus.github.io/LWG/issue2731) + - C++23で、`mutex_type`メンバ型がテンプレート引数を1つだけ持つ場合にのみ定義されることが明確化された diff --git a/reference/mutex/try_lock.md b/reference/mutex/try_lock.md index 5c0685912b..2739bda6cc 100644 --- a/reference/mutex/try_lock.md +++ b/reference/mutex/try_lock.md @@ -112,3 +112,5 @@ int main() ## 参照 - [lock非メンバ関数の使いどころ - yohhoyの日記](http://d.hatena.ne.jp/yohhoy/20120919/p1) - [Acquiring Multiple Locks Without Deadlock](https://www.justsoftwaresolutions.co.uk/threading/acquiring-multiple-locks-without-deadlock.html) +- [LWG Issue 3030. Who shall meet the requirements of `try_lock`?](https://cplusplus.github.io/LWG/issue3030) + - C++20で、効果の記述で利用者要件を表す「shall」を誤用していた箇所が、動作の記述に修正された diff --git a/reference/numeric/adjacent_difference.md b/reference/numeric/adjacent_difference.md index 561c6f3e3f..a54c51a17b 100644 --- a/reference/numeric/adjacent_difference.md +++ b/reference/numeric/adjacent_difference.md @@ -74,11 +74,11 @@ namespace std { - C++11からC++17まで : `InputIterator`が指す値の型のオブジェクト`a`と`b`において、式`binary_op(b, a)`の結果が`result`出力イテレータに書き込めること - C++20から : `InputIterator`が指す値の型のオブジェクト`a`と`b`において、式`binary_op(b,` [`std::move`](/reference/utility/move.md)`(a))`の結果が`result`出力イテレータに書き込めること - (3) : - - `ForwardIterator1`が指す値の型が、[ムーブ代入可能](/reference/type_traits/is_move_assignable.md)であり、`*first`で初期化でき、`ForwardIterator2`が指す値の型に対して代入できること - - `ForwardIterator1`が指す値の型のオブジェクト`a`と`b`において、式`b - a`の結果が、`ForwardIterator2`が指す値の型に対して代入できること + - C++17 : `ForwardIterator1`が指す値の型が、[ムーブ代入可能](/reference/type_traits/is_move_assignable.md)であり、`*first`で初期化でき、`ForwardIterator2`が指す値の型に対して代入できること。かつ、オブジェクト`a`と`b`において式`b - a`の結果が`ForwardIterator2`が指す値の型に対して代入できること + - C++20から : 式`*first`、および式`*first - *first`の結果が、`result`出力イテレータに書き込めること - (4) : - - `ForwardIterator1`が指す値の型が、[ムーブ代入可能](/reference/type_traits/is_move_assignable.md)であり、`*first`で初期化でき、`ForwardIterator2`が指す値の型に対して代入できること - - `ForwardIterator1`が指す値の型のオブジェクト`a`と`b`において、式`binary_op(b, a)`の結果が、`ForwardIterator2`が指す値の型に対して代入できること + - C++17 : `ForwardIterator1`が指す値の型が、[ムーブ代入可能](/reference/type_traits/is_move_assignable.md)であり、`*first`で初期化でき、`ForwardIterator2`が指す値の型に対して代入できること。かつ、オブジェクト`a`と`b`において式`binary_op(b, a)`の結果が`ForwardIterator2`が指す値の型に対して代入できること + - C++20から : 式`*first`、および式`binary_op(*first, *first)`の結果が、`result`出力イテレータに書き込めること ## 効果 @@ -89,11 +89,9 @@ namespace std { - C++17 : (1)であれば`val - acc`、(2)であれば`binary_op(val, acc)`で隣接値を求めて、その結果を`*result`に代入する - C++20 : (1)であれば`val -` [`std::move`](/reference/utility/move.md)`(acc)`、(2)であれば`binary_op(val,` [`std::move`](/reference/utility/move.md)`d(acc))`で隣接値を求めて、その結果を`*result`に代入する 4. `val`を`acc`にムーブ代入し、ひとつ前の位置の値を更新する -- (3), (4) : 非空のイテレータ範囲`[first, last)`について、 - 1. `*result = *first`で結果の初期値を代入する - 2. インデックス範囲`[1, last - first - 1]`のそれぞれの値`d`として定義する - 3. (3)であれば`val = *(first + d) - *(first + d - 1)`、(4)であれば`val = binary_op(*(first + d), *(first + d - 1))`として、隣接値を求める - 4. `*(result + d) = val`で各隣接値を出力する +- (3), (4) : 非空のイテレータ範囲`[first, last)`について、((3)の場合、`binary_op`は[`minus`](/reference/functional/minus.md)`<>`型のオブジェクトとする) + 1. `*result = *first`を行う + 2. インデックス範囲`[1, last - first - 1]`のそれぞれの値`d`について、`*(result + d) = binary_op(*(first + d), *(first + (d - 1)))`を行う ## 戻り値 @@ -204,3 +202,5 @@ OutputIterator adjacent_difference(InputIterator first, InputIterator last, Outp - [P0616R0 De-pessimize legacy `` algorithms with `std::move`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0616r0.pdf) - [P1645R1 `constexpr` for `` algorithms](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1645r1.html) - C++20で、並列バージョン以外の数値計算アルゴリズムが`constexpr`対応した +- [LWG Issue 3058. Parallel `adjacent_difference` shouldn't require creating temporaries](https://cplusplus.github.io/LWG/issue3058) + - C++20で、並列版(3), (4)の効果から中間一時オブジェクトの生成要求が取り除かれ、要件も結果が`result`に書き込み可能であることへ整理された diff --git a/reference/numeric/inclusive_scan.md b/reference/numeric/inclusive_scan.md index f147853cf6..562ecbe632 100644 --- a/reference/numeric/inclusive_scan.md +++ b/reference/numeric/inclusive_scan.md @@ -239,3 +239,5 @@ int main() - [P0574R1: Algorithm Complexity Constraints and Parallel Overloads](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0574r1.html) - [P1645R1 `constexpr` for `` algorithms](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1645r1.html) - C++20で、並列バージョン以外の数値計算アルゴリズムが`constexpr`対応した +- [LWG Issue 3222. P0574R1 introduced preconditions on non-existent parameters](https://cplusplus.github.io/LWG/issue3222) + - C++20で、init無しオーバーロードの事前条件が、存在しないテンプレートパラメータを参照していた誤りを修正するeditorialな整理が行われた diff --git a/reference/numeric/transform_inclusive_scan.md b/reference/numeric/transform_inclusive_scan.md index 2c9c0767d6..298cfc170f 100644 --- a/reference/numeric/transform_inclusive_scan.md +++ b/reference/numeric/transform_inclusive_scan.md @@ -201,3 +201,5 @@ int main() - [P0574R1: Algorithm Complexity Constraints and Parallel Overloads](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0574r1.html) - [P1645R1 `constexpr` for `` algorithms](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1645r1.html) - C++20で、並列バージョン以外の数値計算アルゴリズムが`constexpr`対応した +- [LWG Issue 3222. P0574R1 introduced preconditions on non-existent parameters](https://cplusplus.github.io/LWG/issue3222) + - C++20で、init無しオーバーロードの事前条件が、存在しないテンプレートパラメータを参照していた誤りを修正するeditorialな整理が行われた diff --git a/reference/ranges/common_view/op_constructor.md b/reference/ranges/common_view/op_constructor.md index 34abe284a2..752a0369ff 100644 --- a/reference/ranges/common_view/op_constructor.md +++ b/reference/ranges/common_view/op_constructor.md @@ -66,3 +66,5 @@ int main() { ## 参照 - [N4861 24.7.5.1 Overview](https://timsong-cpp.github.io/cppwp/n4861/range.common.view) +- [LWG Issue 3405. `common_view`'s converting constructor is bad, too](https://cplusplus.github.io/LWG/issue3405) + - C++23で、問題のあった変換コンストラクタテンプレートが`common_view`からも削除された(LWG 3280が他のviewから削除した際の見落としの修正) diff --git a/reference/ranges/disable_sized_range.md b/reference/ranges/disable_sized_range.md index d1e4fdb4c2..899dbeb497 100644 --- a/reference/ranges/disable_sized_range.md +++ b/reference/ranges/disable_sized_range.md @@ -19,9 +19,59 @@ namespace std::ranges { 具体的には、大きさを求めることはできるが、その計算量が償却定数にならないようなRangeが該当する。 +## 要件 + +- cv修飾のないプログラム定義型に対して、この変数テンプレートを特殊化することが許可される。 + - そのような特殊化は定数式で使用可能であり、`const bool`型を持つ必要がある。 + + ## 例 +```cpp example +#include +#include +#include +#include +#include + +// std::forward_listをラップしたRange。 +// size()メンバを持つが、要素を数えるため計算量は要素数に比例する(償却定数ではない) +struct MyRange { + std::forward_list data; + + auto begin() { return data.begin(); } + auto end() { return data.end(); } + + std::size_t size() const { + return static_cast(std::distance(data.begin(), data.end())); + } +}; + +// size()の計算量が償却定数でないため、sized_rangeから除外する +template <> +inline constexpr bool std::ranges::disable_sized_range = true; -(執筆中) +int main() +{ + // disable_sized_rangeをtrueに特殊化したため、 + // size()メンバを持っていてもsized_rangeのモデルにはならない + static_assert(!std::ranges::sized_range); + + // rangeとしては使える + MyRange r{{1, 2, 3}}; + for (int x : r) { + std::cout << x; + } + std::cout << std::endl; +} +``` +* std::ranges::disable_sized_range[color ff0000] +* std::ranges::sized_range[link sized_range.md] +* std::distance[link /reference/iterator/distance.md] + +### 出力 +``` +123 +``` ## バージョン ### 言語 @@ -36,3 +86,5 @@ namespace std::ranges { ## 参照 - [N4861 24 Ranges library](https://timsong-cpp.github.io/cppwp/n4861/ranges) - [C++20 ranges](https://techbookfest.org/product/5134506308665344) +- [LWG Issue 3183. Normative permission to specialize Ranges variable templates](https://cplusplus.github.io/LWG/issue3183) + - C++20で、プログラム定義型に対してこの変数テンプレートを特殊化してよいという規範的な許可が明記された diff --git a/reference/ranges/drop_view/begin.md b/reference/ranges/drop_view/begin.md index d3076e0508..50c7b07d57 100644 --- a/reference/ranges/drop_view/begin.md +++ b/reference/ranges/drop_view/begin.md @@ -7,11 +7,17 @@ ```cpp constexpr auto begin() - requires (!simple-view); // (1) C++20 + requires (!(simple-view && + random_access_range && + sized_range)); // (1) C++20 constexpr auto begin() const - requires range; // (2) C++20 + requires random_access_range && + sized_range; // (2) C++20 ``` +* simple-view[link /reference/ranges/simple-view.md] +* random_access_range[link ../random_access_range.md] +* sized_range[link ../sized_range.md] ## 概要 @@ -68,3 +74,8 @@ int main() { - [GCC](/implementation.md#gcc): 10.1.0 [mark verified] - [ICC](/implementation.md#icc): ? - [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] + + +## 参照 +- [LWG Issue 3482. `drop_view`'s const `begin` should additionally require `sized_range`](https://cplusplus.github.io/LWG/issue3482) + - C++23で、`const`版の`begin()`の制約に[`sized_range`](../sized_range.md)``が追加され、あわせて非`const`版の`begin()`(1)の制約条件も見直された diff --git a/reference/ranges/elements_view/begin.md b/reference/ranges/elements_view/begin.md index f81e217f91..460b6431b8 100644 --- a/reference/ranges/elements_view/begin.md +++ b/reference/ranges/elements_view/begin.md @@ -68,3 +68,5 @@ one ## 参照 - [N4861 24.7.21.1 Overview](https://timsong-cpp.github.io/cppwp/n4861/range.elements.view) +- [LWG Issue 3406. `elements_view::begin()` and `elements_view::end()` have incompatible constraints](https://cplusplus.github.io/LWG/issue3406) + - C++23で、`begin()`と`end()`の制約の整合性が確保されるよう、`const`版`begin()`の制約と`end()`のオーバーロードが整理された diff --git a/reference/ranges/elements_view/end.md b/reference/ranges/elements_view/end.md index 98748e1df9..220610ba94 100644 --- a/reference/ranges/elements_view/end.md +++ b/reference/ranges/elements_view/end.md @@ -81,3 +81,5 @@ one two three ## 参照 - [N4861 24.7.21.1 Overview](https://timsong-cpp.github.io/cppwp/n4861/range.elements.view) +- [LWG Issue 3406. `elements_view::begin()` and `elements_view::end()` have incompatible constraints](https://cplusplus.github.io/LWG/issue3406) + - C++23で、`begin()`と`end()`の制約の整合性が確保されるよう、`const`版`begin()`の制約と`end()`のオーバーロードが整理された diff --git a/reference/ranges/enable_view.md b/reference/ranges/enable_view.md index d254f0ce83..28e5f5164f 100644 --- a/reference/ranges/enable_view.md +++ b/reference/ranges/enable_view.md @@ -19,6 +19,11 @@ namespace std::ranges { [`view`](view.md)コンセプトの要件は意味論要件がメインなため、[`view_base`](view_base.md)を基底クラスにするか、`enable_view`を特殊化することで、明示的に`view`であることを示すようになっている。 +## 要件 + +- cv修飾のないプログラム定義型に対して、この変数テンプレートを特殊化することが許可される。 + - そのような特殊化は定数式で使用可能であり、`bool`型を持つ必要がある。 + ## *is-derived-from-view-interface* `is-derived-from-view-interface`は説明専用の`bool`型の変数テンプレートである。 @@ -71,3 +76,5 @@ int main() - [N4861 24 Ranges library](https://timsong-cpp.github.io/cppwp/n4861/ranges) - [C++20 ranges](https://techbookfest.org/product/5134506308665344) - [LWG Issue 3549. `view_interface` is overspecified to derive from `view_base`](https://cplusplus.github.io/LWG/issue3549) +- [LWG Issue 3183. Normative permission to specialize Ranges variable templates](https://cplusplus.github.io/LWG/issue3183) + - C++20で、プログラム定義型に対してこの変数テンプレートを特殊化してよいという規範的な許可が明記された diff --git a/reference/ranges/join_view.md b/reference/ranges/join_view.md index 37ac449aa2..ba009a3551 100644 --- a/reference/ranges/join_view.md +++ b/reference/ranges/join_view.md @@ -42,7 +42,7 @@ namespace std::ranges { ## 効果 -- (2): 式`views::join(E)`の効果は`join_view{E}`と等しい。 +- (2): 式`views::join(E)`の効果は`join_view<`[`views::all_t`](all.md)`>{E}`と等しい。 ## メンバ関数 @@ -112,4 +112,6 @@ h,e,l,l,o,w,o,r,l,d, ## 参照 - [N4861 24 Ranges library](https://timsong-cpp.github.io/cppwp/n4861/ranges) - [C++20 ranges](https://techbookfest.org/product/5134506308665344) +- [LWG Issue 3474. Nesting `join_views` is broken because of CTAD](https://cplusplus.github.io/LWG/issue3474) + - C++23で、`views::join(E)`の効果が`join_view>{E}`と等価になるよう修正され、CTADによって`join_view`をネストできない問題が解消された - [P2328R1 `join_view` should join all views of ranges](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2328r1.html) diff --git a/reference/ranges/movable_box.md b/reference/ranges/movable_box.md index f276171326..9864c6e423 100644 --- a/reference/ranges/movable_box.md +++ b/reference/ranges/movable_box.md @@ -67,3 +67,5 @@ constexpr movable-box& operator=(movable-box&& that) noexcept(is_nothrow_move_co ## 参照 - [N4950 26 Ranges library](https://timsong-cpp.github.io/cppwp/n4950/ranges) - [P2494R2 Relaxing range adaptors to allow for move only types](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html) +- [LWG Issue 3477. Simplify constraints for _semiregular-box_](https://cplusplus.github.io/LWG/issue3477) + - C++23で、コピー/ムーブ代入演算子を定義する条件が、それぞれ`copyable`・`movable`を用いた形に簡略化された diff --git a/reference/ranges/ref_view/op_deduction_guide.md b/reference/ranges/ref_view/op_deduction_guide.md index 1792e14817..205bfa1158 100644 --- a/reference/ranges/ref_view/op_deduction_guide.md +++ b/reference/ranges/ref_view/op_deduction_guide.md @@ -48,3 +48,8 @@ int main() { - [GCC](/implementation.md#gcc): 10.1.0 [mark verified] - [ICC](/implementation.md#icc): ? - [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] + + +## 参照 +- [LWG Issue 3173. Enable CTAD for `ref-view`](https://cplusplus.github.io/LWG/issue3173) + - C++20で、`ref_view`のクラステンプレート実引数推論(CTAD)を有効にする推論補助が追加された diff --git a/reference/ranges/single_view/op_constructor.md b/reference/ranges/single_view/op_constructor.md index c2ee204456..36c5e7133a 100644 --- a/reference/ranges/single_view/op_constructor.md +++ b/reference/ranges/single_view/op_constructor.md @@ -97,3 +97,5 @@ aaa ## 参照 - [N4861 24.7.4 Filter view](https://timsong-cpp.github.io/cppwp/n4861/range.filter) - [N4950 26.7.8 Filter view](https://timsong-cpp.github.io/cppwp/n4950/range.filter) +- [LWG Issue 3428. `single_view`'s in place constructor should be `explicit`](https://cplusplus.github.io/LWG/issue3428) + - C++23で、`in_place`から構築するコンストラクタ(4)が`explicit`になった diff --git a/reference/ranges/ssize.md b/reference/ranges/ssize.md index 437092cd3e..7c3ebb1692 100644 --- a/reference/ranges/ssize.md +++ b/reference/ranges/ssize.md @@ -16,10 +16,7 @@ namespace std::ranges { Rangeの要素数を符号付き整数型で取得する関数オブジェクト。 ## 効果 -部分式`E`の型を`T`とする。このとき、式`ranges::ssize(E)`の効果は以下の式と等しい。 - -1. [`range_difference_t`](range_difference_t.md)``が[`ptrdiff_t`](/reference/cstddef/ptrdiff_t.md)より狭ければ、`static_cast<`[`ptrdiff_t`](/reference/cstddef/ptrdiff_t.md)`>(`[`ranges::size`](size.md)`(E))`。 -2. それ以外のとき、`static_cast<`[`range_difference_t`](range_difference_t.md)`>(`[`ranges::size`](size.md)`(E))`。 +式`ranges::ssize(E)`は、[`ranges::size`](size.md)`(E)`が有効な式であるときに有効であり、`static_cast(`[`ranges::size`](size.md)`(E))`と等しい。ここで`D`は、`decltype(`[`ranges::size`](size.md)`(E))`を符号付き整数型にした型と[`ptrdiff_t`](/reference/cstddef/ptrdiff_t.md)のうち、幅の広い方の型である。 ## 戻り値 Rangeの要素数。 @@ -70,3 +67,5 @@ int main() ## 参照 - [N4861 24 Ranges library](https://timsong-cpp.github.io/cppwp/n4861/ranges) - [C++20 ranges](https://techbookfest.org/product/5134506308665344) +- [LWG Issue 3403. Domain of `ranges::ssize(E)` doesn't match `ranges::size(E)`](https://cplusplus.github.io/LWG/issue3403) + - C++23で、`ranges::ssize`の定義が`decltype(ranges::size(E))`ベースに書き換えられ、`ranges::size`が有効なら`ranges::ssize`も有効となるようドメインが一致された diff --git a/reference/ranges/subrange/op_constructor.md b/reference/ranges/subrange/op_constructor.md index bb9620ac67..3ff1a6f11b 100644 --- a/reference/ranges/subrange/op_constructor.md +++ b/reference/ranges/subrange/op_constructor.md @@ -126,5 +126,7 @@ int main() - [N4861 24 Ranges library](https://timsong-cpp.github.io/cppwp/n4861/ranges) - [C++20 ranges](https://techbookfest.org/product/5134506308665344) - [P2367R0 Remove misuses of list-initialization from Clause 24](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2367r0.html) (本提案文書はC++20に遡って適用されている) +- [LWG Issue 3179. `subrange` should always model `Range`](https://cplusplus.github.io/LWG/issue3179) + - C++20で、イテレータ・番兵からのコンストラクタに`[i, s)`が有効な範囲であるという事前条件が追加され、`subrange`が常に`Range`のモデルとなることが保証された - [LWG 3281 Conversion from `pair-like` types to `subrange` is a silent semantic promotion](https://cplusplus.github.io/LWG/issue3281) - [LWG 3282 `subrange` converting constructor should disallow derived to base conversions](https://cplusplus.github.io/LWG/issue3282) diff --git a/reference/ranges/subrange/op_deduction_guide.md b/reference/ranges/subrange/op_deduction_guide.md index 3882a20ae4..090a10fd48 100644 --- a/reference/ranges/subrange/op_deduction_guide.md +++ b/reference/ranges/subrange/op_deduction_guide.md @@ -68,3 +68,5 @@ int main() ## 参照 - [N4861 24 Ranges library](https://timsong-cpp.github.io/cppwp/n4861/ranges) - [C++20 ranges](https://techbookfest.org/product/5134506308665344) +- [LWG Issue 3404. Finish removing `subrange`'s conversions from `pair`-like](https://cplusplus.github.io/LWG/issue3404) + - C++23で、LWG 3281/3282が削除した`pair-like`からの変換コンストラクタに対応する推論補助と、不要になった説明専用コンセプトが削除された diff --git a/reference/ranges/take_view/op_deduction_guide.md b/reference/ranges/take_view/op_deduction_guide.md index d429e0f777..b7c6a96386 100644 --- a/reference/ranges/take_view/op_deduction_guide.md +++ b/reference/ranges/take_view/op_deduction_guide.md @@ -54,3 +54,8 @@ int main() { - [GCC](/implementation.md#gcc): 10.1.0 [mark verified] - [ICC](/implementation.md#icc): ? - [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] + + +## 参照 +- [LWG Issue 3447. Deduction guides for `take_view` and `drop_view` have different constraints](https://cplusplus.github.io/LWG/issue3447) + - C++23で、`take_view`の推論補助が`template`に変更され、`drop_view`と制約が統一された diff --git a/reference/ranges/take_while_view/begin.md b/reference/ranges/take_while_view/begin.md index 3c26168454..1aa19b066e 100644 --- a/reference/ranges/take_while_view/begin.md +++ b/reference/ranges/take_while_view/begin.md @@ -64,3 +64,8 @@ int main() { - [GCC](/implementation.md#gcc): 10.1.0 [mark verified] - [ICC](/implementation.md#icc): ? - [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] + + +## 参照 +- [LWG Issue 3450. The const overloads of `take_while_view::begin`/`end` are underconstrained](https://cplusplus.github.io/LWG/issue3450) + - C++23で、`const`版の`begin()`/`end()`の制約に`indirect_unary_predicate>`が追加された diff --git a/reference/ranges/take_while_view/end.md b/reference/ranges/take_while_view/end.md index e9bbfbfdbd..97231abc23 100644 --- a/reference/ranges/take_while_view/end.md +++ b/reference/ranges/take_while_view/end.md @@ -68,3 +68,8 @@ int main() { - [GCC](/implementation.md#gcc): 10.1.0 [mark verified] - [ICC](/implementation.md#icc): ? - [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] + + +## 参照 +- [LWG Issue 3450. The const overloads of `take_while_view::begin`/`end` are underconstrained](https://cplusplus.github.io/LWG/issue3450) + - C++23で、`const`版の`begin()`/`end()`の制約に`indirect_unary_predicate>`が追加された diff --git a/reference/regex/match_results.md b/reference/regex/match_results.md index 7315fb4814..01c56c6944 100644 --- a/reference/regex/match_results.md +++ b/reference/regex/match_results.md @@ -52,7 +52,7 @@ namespace std { また、マッチした文字列だけでなく、マッチした文字列の前([`prefix`](match_results/prefix.md))、および、後([`suffix`](match_results/suffix.md))を指すサブマッチも保持している。 さらに、マッチした結果を用いた書式出力機能も有する([`format`](match_results/format.md))。 -`match_results` はアロケータ対応コンテナの要件のすべて、および、シーケンスコンテナの要件のうち読み取り専用の操作をサポートしている。 +`match_results` はアロケータ対応コンテナの要件のすべてと、シーケンスコンテナの要件のうち読み取り専用の操作に加え、コピー代入・ムーブ代入・[`swap`](match_results/swap.md) をサポートしている。 `match_results` オブジェクトからメンバ関数で取得できるイテレータについて規格では特に言及されていないが、[`operator[]`](match_results/op_at.md) が使用できることから通常ランダムアクセスイテレータであるもの考えても差し支えないものと思われる。 @@ -192,3 +192,10 @@ The C++14 is very cool!! - [GCC](/implementation.md#gcc): 4.9.0 [mark verified], 4.9.1 [mark verified], 4.9.2 [mark verified], 5.0.0 [mark verified] - [ICC](/implementation.md#icc): ?? - [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [LWG Issue 2183. Muddled allocator requirements for `match_results` constructors](https://cplusplus.github.io/LWG/issue2183) + - コンストラクタのアロケータ要件が整理され、`match_results`がアロケータ対応コンテナの規則に従うことが明確化された。C++20に取り込まれたが、矛盾した仕様文言の修正であり実装の挙動は変わらない +- [LWG Issue 2184. Muddled allocator requirements for `match_results` assignments](https://cplusplus.github.io/LWG/issue2184) + - `match_results`が、読み取り専用のシーケンスコンテナ操作に加えてコピー代入・ムーブ代入・swapをサポートすることが明確化された。C++20に取り込まれたが、これらの演算子自体はC++11から存在しており、矛盾した仕様文言の修正であるため実装の挙動は変わらない diff --git a/reference/regex/match_results/get_allocator.md b/reference/regex/match_results/get_allocator.md index 383b691f3f..88d27bb8eb 100644 --- a/reference/regex/match_results/get_allocator.md +++ b/reference/regex/match_results/get_allocator.md @@ -118,3 +118,8 @@ int main() ### 備考 `get_allocator` の問題ではないが、GCC(libstdc++) の 4.9.2 までは代入演算子を使用した場合に正しくアロケータを設定しない。 + + +## 参照 +- [LWG Issue 2183. Muddled allocator requirements for `match_results` constructors](https://cplusplus.github.io/LWG/issue2183) + - C++20で、`match_results`のアロケータ要件が整理され、返されるアロケータが構築時に渡されたもの、または直近の置換後のものであることが明確化された diff --git a/reference/regex/match_results/op_assign.md b/reference/regex/match_results/op_assign.md index 6af53b3ec8..e796934a23 100644 --- a/reference/regex/match_results/op_assign.md +++ b/reference/regex/match_results/op_assign.md @@ -39,19 +39,16 @@ match_results& operator=(match_results&& m) noexcept; // (2) | [`length`](length.md)`()` | `n <` [`size`](size.md)`()` である全ての整数 `n` について、`m.`[`length`](length.md)`(n)` | | [`position`](position.md)`()` | `n <` [`size`](size.md)`()` である全ての整数 `n` について、`m.`[`position`](position.md)`(n)` | +- `match_results`はアロケータを持つコンテナの規則に従い、アロケータについて以下を満たす。 + - (1) : [`allocator_traits`](../../memory/allocator_traits.md)`::propagate_on_container_copy_assignment::value == true` である場合、[`get_allocator`](get_allocator.md)`() == m.`[`get_allocator`](get_allocator.md)`()` + - (2) : [`allocator_traits`](../../memory/allocator_traits.md)`::propagate_on_container_move_assignment::value == true` である場合、[`get_allocator`](get_allocator.md)`() == m.`[`get_allocator`](get_allocator.md)`()` + ## 計算量 - (1) 線形時間 - (2) 線形時間 -## 備考 -規格では明確ではないものの、以下の事後条件を満たすべきであると思われる。 - -- (1) [`allocator_traits`](../../memory/allocator_traits.md)`::propagate_on_container_copy_assignment::value == true` である場合、[`get_allocator`](get_allocator.md)`() == m.`[`get_allocator`](get_allocator.md)`()` -- (2) [`allocator_traits`](../../memory/allocator_traits.md)`::propagate_on_container_move_assignment::value == true` である場合、[`get_allocator`](get_allocator.md)`() == m.`[`get_allocator`](get_allocator.md)`()` - - ## 例 ```cpp example #include @@ -137,4 +134,9 @@ suffix:' ' - [Visual C++](/implementation.md#visual_cpp): ?? ### 備考 -GCC(libstdc++) の 4.9.2 までは、アロケータが上記の備考欄のようには設定されず、また、[`regex_iterator`](../regex_iterator.md) を間接参照した結果を代入した場合に [`position`](position.md) の結果が正しくコピーされない。これは、4.9.3 以降で修正される予定である。 +GCC(libstdc++) の 4.9.2 までは、アロケータが上記の事後条件のようには設定されず、また、[`regex_iterator`](../regex_iterator.md) を間接参照した結果を代入した場合に [`position`](position.md) の結果が正しくコピーされない。これは、4.9.3 以降で修正される予定である。 + + +## 参照 +- [LWG Issue 2184. Muddled allocator requirements for `match_results` assignments](https://cplusplus.github.io/LWG/issue2184) + - コピー代入・ムーブ代入がサポートされることが明確化された。C++11時点の規格は、クラス概要でコピー代入・ムーブ代入演算子を宣言する一方、要件の除外句が「const修飾されたシーケンスコンテナの操作のみサポート」と読め、両者が矛盾していた。この修正はC++20に取り込まれたが、矛盾した文言を正すものであり、演算子自体はC++11から存在してアロケータ対応コンテナの規則に従うため、実装の挙動は変わらない(欠陥修正のため処理系は早期に対応している) diff --git a/reference/regex/match_results/op_constructor.md b/reference/regex/match_results/op_constructor.md index 16a2c5c6ee..e2c6bb7f70 100644 --- a/reference/regex/match_results/op_constructor.md +++ b/reference/regex/match_results/op_constructor.md @@ -65,7 +65,7 @@ match_results(match_results&& m, ## 備考 -規格では明確ではないものの、(3) の形式でも以下の事後条件を満たすべきであると思われる。 +`match_results`はアロケータを持つコンテナの規則に従う。これによりコピーコンストラクタ (3) は、以下の事後条件も満たす。 - (5) の事後条件のアロケータ以外のもの - [`get_allocator`](get_allocator.md)`() ==` [`allocator_traits`](../../memory/allocator_traits.md)`::`[`select_on_container_copy_construction`](../../memory/allocator_traits/select_on_container_copy_construction.md)`(m.`[`get_allocator`](get_allocator.md)`())` @@ -164,5 +164,7 @@ GCC(libstdc++) の 4.9.2 までは、[`regex_iterator`](../regex_iterator.md) ## 参照 - [P0935R0 Eradicating unnecessarily explicit default constructors from the standard library](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html) +- [LWG Issue 2183. Muddled allocator requirements for `match_results` constructors](https://cplusplus.github.io/LWG/issue2183) + - コンストラクタの曖昧なアロケータ要件が整理され、コピー時は`select_on_container_copy_construction`でアロケータを取得し、ムーブ時はアロケータをムーブ構築することが明確化された。この修正はC++20に取り込まれたが、`match_results`はC++11からアロケータ対応コンテナであり、これらのアロケータの扱いはその規則から従うものであるため、実装の挙動は変わらない(欠陥修正のため処理系は早期に対応している) - [LWG Issue 2195. Missing constructors for `match_results`](https://cplusplus.github.io/LWG/issue2195) - C++23で、アロケータを指定するコピーコンストラクタ(4)とムーブコンストラクタ(6)が追加された diff --git a/reference/regex/regex_token_iterator/op_constructor.md b/reference/regex/regex_token_iterator/op_constructor.md index c6b22ca933..fb5b399478 100644 --- a/reference/regex/regex_token_iterator/op_constructor.md +++ b/reference/regex/regex_token_iterator/op_constructor.md @@ -163,3 +163,8 @@ match range = (67, 73), str = 'value3' ### 備考 - libstdc++ には 5.0.0 rev.218373 現在、(6)-(9) の形式のコンストラクタは存在しない。 - libc++ には、3.4 までは (6)-(9) の形式のコンストラクタは存在しない。また、3.0 には (4) の形式のコンストラクタも存在しない。 + + +## 参照 +- [LWG Issue 3129. `regex_token_iterator` constructor uses wrong pointer arithmetic](https://cplusplus.github.io/LWG/issue3129) + - C++20で、配列を受け取るコンストラクタの効果における範囲指定が、配列全体への誤ったポインタ演算から`[begin(submatches), end(submatches))`に修正された diff --git a/reference/scoped_allocator/scoped_allocator_adaptor/construct.md b/reference/scoped_allocator/scoped_allocator_adaptor/construct.md index 023782103a..712d6ccaf9 100644 --- a/reference/scoped_allocator/scoped_allocator_adaptor/construct.md +++ b/reference/scoped_allocator/scoped_allocator_adaptor/construct.md @@ -35,7 +35,7 @@ void construct(pair* p, pair&& x); // (6) C++17 ま 説明を簡略化するために、以下の説明用関数を使用する。 - `OUTERMOST(x)` は、`x` が [`outer_allocator()`](outer_allocator.md) メンバ関数を持っている場合は `OUTERMOST(x.`[`outer_allocator()`](outer_allocator.md)`)` を、持っていない場合は `x` を返す。 -- `CONSTRUCT(...)` は、[`allocator_traits`](/reference/memory/allocator_traits.md)`::`[`construct`](/reference/memory/allocator_traits/construct.md)`(OUTERMOST(*this), p, ...)` とする。 +- `CONSTRUCT(...)` は、[`allocator_traits`](/reference/memory/allocator_traits.md)`<`[`remove_reference_t`](/reference/type_traits/remove_reference.md)`>::`[`construct`](/reference/memory/allocator_traits/construct.md)`(OUTERMOST(*this), p, ...)` とする。 - (1) : - C++17 まで : 以下のいずれかの動作を行う。 @@ -236,3 +236,5 @@ int main() ## 参照 - [P0591R4 Utility functions to implement uses-allocator construction](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0591r4.pdf) - [LWG Issue 2975. Missing case for pair construction in scoped and polymorphic allocators](https://wg21.cmeerw.net/lwg/issue2975) +- [LWG Issue 3116. `OUTERMOST_ALLOC_TRAITS` needs `remove_reference_t`](https://cplusplus.github.io/LWG/issue3116) + - C++20で、`OUTERMOST(x)`が参照を返しうることに対応し、`OUTERMOST_ALLOC_TRAITS`の定義に[`remove_reference_t`](/reference/type_traits/remove_reference.md)が挿入された diff --git a/reference/scoped_allocator/scoped_allocator_adaptor/destroy.md b/reference/scoped_allocator/scoped_allocator_adaptor/destroy.md index cea6eedd57..684424f5b8 100644 --- a/reference/scoped_allocator/scoped_allocator_adaptor/destroy.md +++ b/reference/scoped_allocator/scoped_allocator_adaptor/destroy.md @@ -19,7 +19,7 @@ void destroy(T* p); この関数において、以下の名称定義を行う。 - `OUTERMOST(x)`関数は、アロケータオブジェクト`x`が`outer_allocator()`メンバ関数を持っている場合、その関数によって返されるアロケータを返す。そうでない場合は、`x`を返す。 -- [`allocator_traits`](/reference/memory/allocator_traits.md)``を`OUTERMOST_ALLOC_TRAITS(x)`とする。 +- [`allocator_traits`](/reference/memory/allocator_traits.md)`<`[`remove_reference_t`](/reference/type_traits/remove_reference.md)`>`を`OUTERMOST_ALLOC_TRAITS(x)`とする。 この定義の元に、以下の関数呼び出しを行う: @@ -90,3 +90,8 @@ int main() - [GCC](/implementation.md#gcc): 4.7.3 [mark verified] - [ICC](/implementation.md#icc): ?? - [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [LWG Issue 3116. `OUTERMOST_ALLOC_TRAITS` needs `remove_reference_t`](https://cplusplus.github.io/LWG/issue3116) + - C++20で、`OUTERMOST(x)`が参照を返しうることに対応し、`OUTERMOST_ALLOC_TRAITS`の定義に[`remove_reference_t`](/reference/type_traits/remove_reference.md)が挿入された diff --git a/reference/sstream/basic_stringbuf/op_constructor.md b/reference/sstream/basic_stringbuf/op_constructor.md index ba24f7c55e..9dd0880d4e 100644 --- a/reference/sstream/basic_stringbuf/op_constructor.md +++ b/reference/sstream/basic_stringbuf/op_constructor.md @@ -176,3 +176,5 @@ from string_view - [P0408R7 Efficient Access to `basic_stringbuf`'s Buffer](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0408r7.pdf) - [P2495R3 Interfacing stringstreams with `string_view`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2495r3.pdf) - C++26で[`std::string_view`](/reference/string_view/basic_string_view.md)に対応した +- [LWG Issue 2995. `basic_stringbuf` default constructor forbids it from using SSO capacity](https://cplusplus.github.io/LWG/issue2995) + - C++20で、デフォルト構築時にシーケンスポインタがヌルポインタに初期化されるかどうかが実装定義とされ、SSO領域を利用できるようになった diff --git a/reference/string/basic_string/op_constructor.md b/reference/string/basic_string/op_constructor.md index f42f45a153..850de1bf11 100644 --- a/reference/string/basic_string/op_constructor.md +++ b/reference/string/basic_string/op_constructor.md @@ -178,6 +178,7 @@ constexpr basic_string(from_range_t, R&& rg, ``` のようなコード(C++11 から導入された、コピーリスト初期化によるデフォルトコンストラクタ呼び出し)がエラーになってしまうためである。 +- C++20 では、(8), (9) は、`Allocator`がアロケータの要件を満たさない型の場合、オーバーロード解決に参加しない。これは、クラステンプレートの実引数推論 (CTAD) における曖昧性を回避するための制約である。 ## 例 @@ -265,6 +266,8 @@ s14 : Hello - `string_view`から範囲を指定して構築する(15)を追加 - [LWG Issue 2946. LWG 2758's resolution missed further corrections](https://wg21.cmeerw.net/lwg/issue2946) - 意図しない暗黙変換防止のために`string_view`を受けるオーバーロード(14)の引数型を`const T&`に変更 +- [LWG Issue 3076. `basic_string` CTAD ambiguity](https://cplusplus.github.io/LWG/issue3076) + - C++20で、(8), (9)に`Allocator`がアロケータ要件を満たさない型の場合はオーバーロード解決に参加しないという制約が追加され、クラステンプレート実引数推論(CTAD)の曖昧性が解消された - [P0980R1 Making `std::string` constexpr](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0980r1.pdf) - [P2166R1 A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr.](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2166r1.html) - C++23での(16)`nullptr_t`をとるコンストラクタのdelete宣言追加 diff --git a/reference/string_view/basic_string_view/op_compare_3way.md b/reference/string_view/basic_string_view/op_compare_3way.md index 008738f809..fa4d24182d 100644 --- a/reference/string_view/basic_string_view/op_compare_3way.md +++ b/reference/string_view/basic_string_view/op_compare_3way.md @@ -22,6 +22,10 @@ namespace std { `basic_string_view`オブジェクトの三方比較を行う。 +## 適格要件 +戻り値の型`R`(`traits::comparison_category`が存在すればその型)が、比較カテゴリ型([`strong_ordering`](/reference/compare/strong_ordering.md)・[`weak_ordering`](/reference/compare/weak_ordering.md)・[`partial_ordering`](/reference/compare/partial_ordering.md)のいずれか)であること。満たさない場合、この演算子の使用はプログラムを不適格とする。 + + ## 戻り値 戻り値の型`R`は、`traits::comparison_category`が存在していればその型、そうでなければ[`weak_ordering`](/reference/compare/weak_ordering.md)となり、以下と等価: @@ -79,3 +83,5 @@ equal - C++20での三方比較演算子の追加と、関連する演算子の自動導出 - [LWG Issue 3950. `std::basic_string_view` comparison operators are overspecified](https://cplusplus.github.io/LWG/issue3950) - C++26で、第2引数が`type_identity_t`で包まれ、`basic_string_view`へ暗黙変換可能な型と直接比較できるようになった(追加の比較オーバーロードの規定が不要になった) +- [LWG Issue 3432. Missing requirement for `comparison_category`](https://cplusplus.github.io/LWG/issue3432) + - C++23で、戻り値型`R`が比較カテゴリ型でなければならないという要件(Mandates)が追加され、`traits::comparison_category`が妥当な型を示す場合にのみ使われることが明確化された diff --git a/reference/syncstream/basic_osyncstream/rdbuf.md b/reference/syncstream/basic_osyncstream/rdbuf.md index 08d401319f..316bd1b33e 100644 --- a/reference/syncstream/basic_osyncstream/rdbuf.md +++ b/reference/syncstream/basic_osyncstream/rdbuf.md @@ -59,4 +59,6 @@ Hello, World! ## 参照 - [P0053R7 C++ Synchronized Buffered Ostream](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0053r7.pdf) +- [LWG Issue 3127. `basic_osyncstream::rdbuf` needs a `const_cast`](https://cplusplus.github.io/LWG/issue3127) + - C++20で、const版の`rdbuf()`が非const版の`syncbuf_type*`を返せるよう、戻り値に`const_cast`が追加された - [LWG Issue 3130. §[input.output] needs many `addressof`](https://wg21.cmeerw.net/lwg/issue3130) diff --git a/reference/syncstream/basic_syncbuf/op_constructor.md b/reference/syncstream/basic_syncbuf/op_constructor.md index a8eb87ea85..b79b89b3e5 100644 --- a/reference/syncstream/basic_syncbuf/op_constructor.md +++ b/reference/syncstream/basic_syncbuf/op_constructor.md @@ -7,39 +7,41 @@ ```cpp -explicit basic_syncbuf(streambuf_type* obuf = nullptr) - : basic_syncbuf(obuf, Allocator()) { } // (1) -basic_syncbuf(streambuf_type* obuf, const Allocator& allocator); // (2) -basic_syncbuf(basic_syncbuf&& other); // (3) +basic_syncbuf() : basic_syncbuf(nullptr) {} // (1) C++20 +explicit basic_syncbuf(streambuf_type* obuf) + : basic_syncbuf(obuf, Allocator()) { } // (2) C++20 +basic_syncbuf(streambuf_type* obuf, const Allocator& allocator); // (3) C++20 +basic_syncbuf(basic_syncbuf&& other); // (4) C++20 ``` ## 概要 -- (1) : デフォルトコンストラクタ。ラップする[`std::basic_streambuf`](../../streambuf/basic_streambuf.md)へのポインタを受け取る。 -- (2) : ラップする`std::basic_streambuf`へのポインタ、アロケータを受け取る。 -- (3) : ムーブコンストラクタ。 +- (1) : デフォルトコンストラクタ。 +- (2) : ラップする[`std::basic_streambuf`](../../streambuf/basic_streambuf.md)へのポインタを受け取る。 +- (3) : ラップする`std::basic_streambuf`へのポインタ、アロケータを受け取る。 +- (4) : ムーブコンストラクタ。 ただし、これらは通常[`std::basic_osyncstream`](../basic_osyncstream.md)から呼ばれる。 ## 効果 -- (1), (2) : 同期時排出ポリシー([`sync()`](sync.md)が呼ばれたとき[`emit()`](emit.md)を呼び出すかどうか)を`false`に設定し、`std::basic_syncbuf`オブジェクトを作成し、ラップされたストリームバッファを`obuf`に設定する。`obuf`が、関連する出力の最終的な宛先になる。 -- (3) : 他のオブジェクトからムーブコンストラクトする。 +- (1), (2), (3) : 同期時排出ポリシー([`sync()`](sync.md)が呼ばれたとき[`emit()`](emit.md)を呼び出すかどうか)を`false`に設定し、`std::basic_syncbuf`オブジェクトを作成し、ラップされたストリームバッファを`obuf`に設定する((1)では`nullptr`)。`obuf`が、関連する出力の最終的な宛先になる。 +- (4) : 他のオブジェクトからムーブコンストラクトする。 ## 例外 -- (1), (2) : ミューテックスの構築から[`std::system_error`](../../system_error/system_error.md)、またはメモリ割り当てによって[`std::bad_alloc`](../../new/bad_alloc.md)例外が送出される可能性がある。 +- (1), (2), (3) : ミューテックスの構築から[`std::system_error`](../../system_error/system_error.md)、またはメモリ割り当てによって[`std::bad_alloc`](../../new/bad_alloc.md)例外が送出される可能性がある。 ## 事後条件 -- (1), (2) : `get_wrapped() == obuf`と`get_allocator() == allocator`が`true`となる。 -- (3) : `this->get_wrapped()`によって返される値は、このコンストラクタを呼び出す前に`other.get_wrapped()`によって返される値である。 +- (1), (2), (3) : `get_wrapped() == obuf`と`get_allocator() == allocator`が`true`となる。 +- (4) : `this->get_wrapped()`によって返される値は、このコンストラクタを呼び出す前に`other.get_wrapped()`によって返される値である。 このコンストラクタを呼び出す前に`other`に格納された出力は、`*this`に格納される。 `other.rdbuf()->pbase() == other.rdbuf()->pptr()`と`other.get_wrapped() == nullptr`は`true`である。 ## 備考 -- (1), (2) : アロケータのコピーは、関連する出力を保持する内部バッファにメモリを割り当てるために使用される。 -- (3) : このコンストラクタは、`other`をそのラップされたストリームバッファから切り離し、`other`の破棄によって出力がされないようにする。 +- (1), (2), (3) : アロケータのコピーは、関連する出力を保持する内部バッファにメモリを割り当てるために使用される。 +- (4) : このコンストラクタは、`other`をそのラップされたストリームバッファから切り離し、`other`の破棄によって出力がされないようにする。 ## 例 @@ -72,3 +74,5 @@ Hello, World! ## 参照 - [P0053R7 C++ Synchronized Buffered Ostream](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0053r7.pdf) +- [LWG Issue 3253. `basic_syncbuf::basic_syncbuf()` should not be `explicit`](https://cplusplus.github.io/LWG/issue3253) + - C++20で、非explicitなデフォルトコンストラクタ(1)が分離して新設され、`explicit`版のデフォルト引数`= nullptr`が削除された diff --git a/reference/system_error/system_category.md b/reference/system_error/system_category.md index 0f7cd76106..a2d173c5b4 100644 --- a/reference/system_error/system_category.md +++ b/reference/system_error/system_category.md @@ -24,7 +24,10 @@ namespace std { - [`name()`](error_category/name.md)関数によって返される文字列は`"system"` - [`equivalent()`](error_category/equivalent.md)仮想関数の挙動は、基底クラスである[`error_category`](error_category.md)と同じである -- [`default_error_condition()`](error_category/default_error_condition.md)仮想関数は、パラメータ`ev`が`0`であるか、POSIXの`errno`に対応する値であった場合 [`error_condition`](error_condition.md)`(ev,` [`generic_category()`](generic_category.md)`);` を返し、そうでない場合は[`error_condition`](error_condition.md)`(ev, system_category());` を返す。特定のOSに関する処理は未規定。ただし、POSIXのエラー値に対応していない場合がありえるため、環境によっては[`generic_category()`](generic_category.md)が返される挙動はサポートされない。 +- [`default_error_condition()`](error_category/default_error_condition.md)仮想関数は、パラメータ`ev`がPOSIXの`errno`に対応する値であった場合 [`error_condition`](error_condition.md)`(ev,` [`generic_category()`](generic_category.md)`);` を返し、そうでない場合は[`error_condition`](error_condition.md)`(ev, system_category());` を返す。特定のOSに関する処理は未規定。ただし、POSIXのエラー値に対応していない場合がありえるため、環境によっては[`generic_category()`](generic_category.md)が返される挙動はサポートされない。 + - 引数`ev`が`0`の場合の扱いは、バージョンによって異なる。 + - C++11 : `0`はPOSIXの`errno`に対応しないため、[`system_category()`](system_category.md)側の[`error_condition`](error_condition.md)が返されうる + - C++23 : `ev`が`0`の場合は[`error_condition`](error_condition.md)`(0,` [`generic_category()`](generic_category.md)`);` を返す ## 例外 diff --git a/reference/thread/jthread/op_constructor.md b/reference/thread/jthread/op_constructor.md index 3263760169..e0f5cd2135 100644 --- a/reference/thread/jthread/op_constructor.md +++ b/reference/thread/jthread/op_constructor.md @@ -161,3 +161,8 @@ int main() - [Clang](/implementation.md#clang): - [GCC](/implementation.md#gcc): 10.2.0 [mark verified] - [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [LWG Issue 3476. `thread` and `jthread` constructors require that the parameters be move-constructible](https://cplusplus.github.io/LWG/issue3476) + - C++23で、`is_constructible`要件が既に目的を満たすため、冗長だったムーブ構築可能(`is_move_constructible`)の要件が削除された diff --git a/reference/thread/thread/op_constructor.md b/reference/thread/thread/op_constructor.md index 5caff43ef7..a3ad1132b8 100644 --- a/reference/thread/thread/op_constructor.md +++ b/reference/thread/thread/op_constructor.md @@ -24,7 +24,8 @@ thread(thread&&) noexcept; // (4) ## 要件 -- (2) : 型`F`および`Args`に含まれるすべての型`Ti`はムーブコンストラクト可能な型でなければならない。また、[`INVOKE`](/reference/concepts/Invoke.md)`(DECAY_COPY(`[`std::forward`](/reference/utility/forward.md)`(f)), DECAY_COPY(`[`std::forward`](/reference/utility/forward.md)`(args))...)`が有効な式でなければならない。 +- (2) : [`INVOKE`](/reference/concepts/Invoke.md)`(DECAY_COPY(`[`std::forward`](/reference/utility/forward.md)`(f)), DECAY_COPY(`[`std::forward`](/reference/utility/forward.md)`(args))...)`が有効な式でなければならない。 + - C++20まで : これに加えて、型`F`および`Args`に含まれるすべての型`Ti`がムーブコンストラクト可能な型でなければならなかった。C++23では、`is_constructible`要件が既に目的を満たすため、この要件は削除された。 ## 効果 @@ -112,3 +113,5 @@ int main() ## 参照 - [LWG Issue 2097. `packaged_task` constructors should be constrained](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2097) - [LWG Issue 3039. Unnecessary `decay` in `thread` and `packaged_task`](https://wg21.cmeerw.net/lwg/issue3039) +- [LWG Issue 3476. `thread` and `jthread` constructors require that the parameters be move-constructible](https://cplusplus.github.io/LWG/issue3476) + - C++23で、`is_constructible`要件が既に目的を満たすため、冗長だったムーブ構築可能(`is_move_constructible`)の要件が削除された diff --git a/reference/tuple/tuple/op_constructor.md b/reference/tuple/tuple/op_constructor.md index b67f7041d5..5fd0a575f3 100644 --- a/reference/tuple/tuple/op_constructor.md +++ b/reference/tuple/tuple/op_constructor.md @@ -308,6 +308,7 @@ explicit(see below) constexpr ## 備考 - (1) : - C++17 : `Types...`のうちいずれかの型が非暗黙にデフォルト構築できる場合、この関数は`explicit`となる + - C++23 : `sizeof...(Types) == 0`(空の`tuple<>`)の場合、このデフォルトコンストラクタはトリビアルである - (2) : - C++11からC++14まで : 無条件で`explicit`となる - C++17から : `!`[`conjunction_v`](/reference/type_traits/conjunction.md)`<`[`is_convertible`](/reference/type_traits/is_convertible.md)`...>`である場合、この関数は`explicit`となる @@ -455,3 +456,9 @@ int main() - すべての要素が[プロキシ参照](/reference/iterator/indirectly_writable.md)の場合、[プロキシ参照](/reference/iterator/indirectly_writable.md)として使用できるようにする - [LWG Issue 4045. `tuple` can create dangling references from `tuple-like`](https://cplusplus.github.io/LWG/issue4045) - C++26で、[`tuple-like`](../tuple-like.md)なオブジェクトから構築するコンストラクタ(14)について、いずれかの要素がダングリング参照を作成する場合に削除定義されることが規定された(C++23での`tuple-like`コンストラクタ導入時に欠けていた保護の追加) +- [LWG Issue 3158. `tuple(allocator_arg_t, const Alloc&)` should be conditionally `explicit`](https://cplusplus.github.io/LWG/issue3158) + - C++20で、アロケータ拡張デフォルトコンストラクタ(15)が、非アロケータ版(1)と同じ条件で`explicit`となるよう修正された +- [LWG Issue 2899. `is_(nothrow_)move_constructible` and `tuple`, `optional` and `unique_ptr`](https://cplusplus.github.io/LWG/issue2899) + - C++20で、ムーブコンストラクタ(5)が、いずれかの要素型がムーブ構築可能でない場合はオーバーロード解決に参加しないよう制約化された +- [LWG Issue 3211. `std::tuple<>` should be trivially constructible](https://cplusplus.github.io/LWG/issue3211) + - C++23で、空の`tuple<>`のデフォルトコンストラクタがトリビアルであることが規定された diff --git a/reference/type_traits/aligned_storage.md b/reference/type_traits/aligned_storage.md index 467b1aad3f..8082f2422b 100644 --- a/reference/type_traits/aligned_storage.md +++ b/reference/type_traits/aligned_storage.md @@ -35,7 +35,7 @@ namespace std { - `aligned_storage`は、領域サイズ`Len`、アライメント`Align`で調整した未初期化領域をメンバ型`type`として定義する。 - メンバ型`type`は以下の型に分類されること: - C++11 : [POD型](is_pod.md) - - C++20 : [トリビアル型](is_trivial.md) + - C++20 : [トリビアル型](is_trivial.md)かつ[標準レイアウト型](is_standard_layout.md) `Align`のデフォルト値は、`Len`よりも大きくない、最も厳格なアライメント要件を持つ、C++の何らかのオブジェクト型のアライメント値。 @@ -215,5 +215,7 @@ int main() - C++14で`aligned_storage_t`が定義された - [P0767R1 Deprecate POD](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0767r1.html) - C++20でPOD用語の非推奨化にともない、メンバ型`type`がPOD型ではなくトリビアル型に分類されるよう規定が変更された +- [LWG Issue 3034. P0767R1 breaks previously-standard-layout types](https://cplusplus.github.io/LWG/issue3034) + - C++20で、P0767R1がPOD要件をトリビアル要件へ置き換えた際に標準レイアウト性が欠落していたため、メンバ型`type`がトリビアルかつ標準レイアウトであることが要件として補われた - [P1413R3 Deprecate `std::aligned_storage` and `std::aligned_union`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf) - C++23でこの機能が非推奨となった diff --git a/reference/type_traits/aligned_union.md b/reference/type_traits/aligned_union.md index 606f7d2a53..d51a4c871f 100644 --- a/reference/type_traits/aligned_union.md +++ b/reference/type_traits/aligned_union.md @@ -34,7 +34,7 @@ namespace std { - `aligned_union`は、領域サイズ`Len`、要素型列`Types...`で調整した未初期化の共用体領域をメンバ型`type`として定義する。 - メンバ型`type`は、以下の型分類となる: - C++11 : `Types...`のいずれかの型が非POD型だとしても、メンバ型`type`は[POD型](is_pod.md)となる - - C++20 : `Types...`のいずれかの型が非トリビアル型だとしても、メンバ型`type`は[トリビアル型](is_trivial.md)となる + - C++20 : `Types...`のいずれかの型が非トリビアル型だとしても、メンバ型`type`は[トリビアル型](is_trivial.md)かつ[標準レイアウト型](is_standard_layout.md)となる また、`Types...`全ての厳格なアライメント値を、[`std::size_t`](/reference/cstddef/size_t.md)型の静的メンバ定数`alignment_value`として定義する。 @@ -132,5 +132,7 @@ hello - [LWG Issue 2979. `aligned_union` should require complete object types](https://wg21.cmeerw.net/lwg/issue2979) - [P0767R1 Deprecate POD](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0767r1.html) - C++20でPOD用語の非推奨化にともない、メンバ型`type`がPOD型ではなくトリビアル型に分類されるよう規定が変更された +- [LWG Issue 3034. P0767R1 breaks previously-standard-layout types](https://cplusplus.github.io/LWG/issue3034) + - C++20で、P0767R1がPOD要件をトリビアル要件へ置き換えた際に標準レイアウト性が欠落していたため、メンバ型`type`がトリビアルかつ標準レイアウトであることが要件として補われた - [P1413R3 Deprecate `std::aligned_storage` and `std::aligned_union`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf) - C++23でこの機能が非推奨となった diff --git a/reference/type_traits/unwrap_ref_decay.md b/reference/type_traits/unwrap_ref_decay.md index 090f417642..187c10ab82 100644 --- a/reference/type_traits/unwrap_ref_decay.md +++ b/reference/type_traits/unwrap_ref_decay.md @@ -110,4 +110,6 @@ int main() ## 参照 - [P0318R1 `unwrap_ref_decay` and `unwrap_reference`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0318r1.pdf) +- [LWG Issue 3202. P0318R1 was supposed to be revised](https://cplusplus.github.io/LWG/issue3202) + - C++20で、P0318R1の改訂漏れにより漏れていた`unwrap_reference`/`unwrap_reference_t`/`unwrap_ref_decay`/`unwrap_ref_decay_t`が``シノプシスに追加された - [LWG Issue 3348. `__cpp_lib_unwrap_ref` in wrong header](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2117r0.html#3348) diff --git a/reference/type_traits/unwrap_reference.md b/reference/type_traits/unwrap_reference.md index 70ec485ce7..fc6b664f63 100644 --- a/reference/type_traits/unwrap_reference.md +++ b/reference/type_traits/unwrap_reference.md @@ -105,4 +105,6 @@ namespace std { ## 参照 - [P0318R1 `unwrap_ref_decay` and `unwrap_reference`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0318r1.pdf) +- [LWG Issue 3202. P0318R1 was supposed to be revised](https://cplusplus.github.io/LWG/issue3202) + - C++20で、P0318R1の改訂漏れにより漏れていた`unwrap_reference`/`unwrap_reference_t`/`unwrap_ref_decay`/`unwrap_ref_decay_t`が``シノプシスに追加された - [LWG Issue 3348. `__cpp_lib_unwrap_ref` in wrong header](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2117r0.html#3348) diff --git a/reference/vector/vector/emplace.md b/reference/vector/vector/emplace.md index 21a9e50ac2..ef2d0cc7ea 100644 --- a/reference/vector/vector/emplace.md +++ b/reference/vector/vector/emplace.md @@ -45,6 +45,9 @@ constexpr iterator ## 備考 - 再確保の可能性、イテレータの有効性への影響、例外発生時に副作用が発生しない保証はいずれも[`insert()`](insert.md)と同様。 +- 引数`args`がこのコンテナ自身の要素を参照する場合の扱いは、バージョンによって以下のように異なる: + - C++17まで : 引数`args`がコンテナ自身の要素を参照する場合の動作は規定されていない + - C++20 : 引数`args`は、このコンテナ自身の要素を直接的または間接的に参照してもよい。たとえば`v.emplace(v.begin(), v.back())`のように、末尾要素を先頭に挿入する操作も正しく動作する ## 例 @@ -93,3 +96,5 @@ int main() - [LWG Issue 2252. Strong guarantee on `vector::push_back()` still broken with C++11?](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2252) - 経緯の説明は、[`vector::push_back()`](/reference/vector/vector/push_back.md)ページを参照。 - [P1004R2 Making `std::vector` constexpr](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1004r2.pdf) +- [LWG Issue 2164. What are the semantics of `vector.emplace(vector.begin(), vector.back())`?](https://cplusplus.github.io/LWG/issue2164) + - C++20で、引数がコンテナ自身の要素を参照してもよいことが明確化された diff --git a/reference/vector/vector/emplace_back.md b/reference/vector/vector/emplace_back.md index e02d56747f..5a7c976654 100644 --- a/reference/vector/vector/emplace_back.md +++ b/reference/vector/vector/emplace_back.md @@ -93,3 +93,5 @@ int main() - [P0084R1 Emplace Return Type (Revision 1)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r1.pdf) - [P0084R2 Emplace Return Type (Revision 2)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r2.pdf) - [P1004R2 Making `std::vector` constexpr](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1004r2.pdf) +- [LWG Issue 3077. `(push`|`emplace)_back` should invalidate the end iterator](https://cplusplus.github.io/LWG/issue3077) + - C++20で、再確保が生じない場合でも終端 (past-the-end) イテレータが無効化されることが明確化された diff --git a/reference/vector/vector/push_back.md b/reference/vector/vector/push_back.md index 5f9d4e9a98..e2415d4589 100644 --- a/reference/vector/vector/push_back.md +++ b/reference/vector/vector/push_back.md @@ -43,7 +43,9 @@ constexpr void push_back(T&& x); // (2) C++20 ## 備考 -- 要素を追加した後の[`size()`](size.md)が要素を追加する前の[`capacity()`](capacity.md)よりも大きい場合は領域の再確保が生じる。領域の再確保が生じなかった場合には全てのイテレータや参照は有効である。 +- 要素を追加した後の[`size()`](size.md)が要素を追加する前の[`capacity()`](capacity.md)よりも大きい場合は領域の再確保が生じる。領域の再確保が生じた場合は、全てのイテレータ・参照・ポインタが無効になる(終端 (past-the-end) イテレータを含む)。領域の再確保が生じなかった場合の終端 (past-the-end) イテレータの扱いは、バージョンによって異なる。 + - C++03 : 終端イテレータが無効化されるとは規定されていない(挿入位置より前のイテレータ・参照のみ有効性が保証される) + - C++20 : 終端イテレータは無効になる。それ以外のイテレータや参照は有効である - 非コピー挿入可能な要素型`T`のムーブコンストラクタ以外で例外が発生した場合、副作用は発生しない。 @@ -96,3 +98,5 @@ world - `deque`の[`emplace_back()`](/reference/deque/deque/emplace_back.md)と[`emplace_front()`](/reference/deque/deque/emplace_front.md) (C++14から) - `deque`の両端へ単一要素を挿入する[`insert()`](/reference/deque/deque/insert.md)と[`emplace()`](/reference/deque/deque/emplace.md) (C++14) - [P1004R2 Making `std::vector` constexpr](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1004r2.pdf) +- [LWG Issue 3077. `(push`|`emplace)_back` should invalidate the end iterator](https://cplusplus.github.io/LWG/issue3077) + - C++20で、再確保が生じない場合でも終端 (past-the-end) イテレータが無効化されることが明確化された