22<feed xmlns="http://www.w3.org/2005/Atom">
33 <title>cpprefjp - C++日本語リファレンス</title>
44 <link href="https://cpprefjp.github.io" />
5- <updated>2024-12-18T05:19:36.717043 </updated>
6- <id>acdb137e-8f7f-4170-be6f-5da61dd8c3c5 </id>
5+ <updated>2024-12-18T07:44:26.447126 </updated>
6+ <id>efe7e658-74ec-486c-9ea8-b4ad56360616 </id>
77
88
9+ <entry>
10+ <title>gcd -- added a sample implementation for gcd and lcm function</title>
11+ <link href="https://cpprefjp.github.io/reference/numeric/gcd.html"/>
12+ <id>5b5cd374f837f54793bc5f633d6926211370a230:reference/numeric/gcd.md</id>
13+ <updated>2024-12-18T16:39:06+09:00</updated>
14+
15+ <summary type="html"><pre><code>diff --git a/reference/numeric/gcd.md b/reference/numeric/gcd.md
16+ index 1e2049b6d..5bf7c51aa 100644
17+ --- a/reference/numeric/gcd.md
18+ +++ b/reference/numeric/gcd.md
19+ @@ -129,6 +129,7 @@ int main() {
20+ ```
21+ ```
22+
23+ +
24+ ## バージョン
25+ ### 言語
26+ - C++17
27+ @@ -167,3 +168,22 @@ $$ \mathrm{gcd}(m, n) = \begin{cases}
28+ |m| &amp; \text{if } n = 0 \\
29+ \mathrm{gcd}(n, m \bmod n) &amp; \text{otherwise}
30+ \end{cases} $$
31+ +
32+ +
33+ +```cpp
34+ +template &lt;class M, class N&gt;
35+ +constexpr std::common_type_t&lt;M, N&gt; gcd(M m, N n) {
36+ + if (m == 0 &amp;&amp; n == 0) {
37+ + return 0;
38+ + }
39+ + while (m != 0 &amp;&amp; n != 0) {
40+ + if (m &gt; n) {
41+ + m %= n;
42+ + }
43+ + else {
44+ + n %= m;
45+ + }
46+ + }
47+ + return m &lt; n ? n : m;
48+ +}
49+ +```
50+ </code></pre></summary>
51+
52+ <author>
53+ <name>rotarymars</name>
54+ <email>s.goto2050@gmail.com</email>
55+ </author>
56+ </entry>
57+
58+ <entry>
59+ <title>lcm -- added a sample implementation for gcd and lcm function</title>
60+ <link href="https://cpprefjp.github.io/reference/numeric/lcm.html"/>
61+ <id>5b5cd374f837f54793bc5f633d6926211370a230:reference/numeric/lcm.md</id>
62+ <updated>2024-12-18T16:39:06+09:00</updated>
63+
64+ <summary type="html"><pre><code>diff --git a/reference/numeric/lcm.md b/reference/numeric/lcm.md
65+ index fb9a9f5c1..cdea96876 100644
66+ --- a/reference/numeric/lcm.md
67+ +++ b/reference/numeric/lcm.md
68+ @@ -171,3 +171,26 @@ int main() {
69+
70+ ## 実装例
71+ $$ \mathrm{lcm}(m, n) = \frac{|mn|}{\mathrm{gcd}(m, n)} $$
72+ +
73+ +```cpp
74+ +template &lt;class M, class N&gt;
75+ +constexpr std::common_type_t&lt;M, N&gt; gcd(M m, N n) {
76+ + if (m == 0 &amp;&amp; n == 0) {
77+ + return 0;
78+ + }
79+ + while (m != 0 &amp;&amp; n != 0) {
80+ + if (m &gt; n) {
81+ + m %= n;
82+ + }
83+ + else {
84+ + n %= m;
85+ + }
86+ + }
87+ + return m &lt; n ? n : m;
88+ +}
89+ +
90+ +template &lt;class M, class N&gt;
91+ +constexpr std::common_type_t&lt;M, N&gt; lcm(M m, N n) {
92+ + return m / gcd(m, n) * n;
93+ +}
94+ +```
95+ \ No newline at end of file
96+ </code></pre></summary>
97+
98+ <author>
99+ <name>rotarymars</name>
100+ <email>s.goto2050@gmail.com</email>
101+ </author>
102+ </entry>
103+
9104 <entry>
10105 <title>basic_istringstream -- Merge pull request #1370 from rotarymars/master</title>
11106 <link href="https://cpprefjp.github.io/reference/sstream/basic_istringstream.html"/>
@@ -516,57 +611,4 @@ index 5d281f66e..30d8cfa41 100644
516611 </author>
517612 </entry>
518613
519- <entry>
520- <title>属性構文 [N2761] -- C++11 属性構文 : indeterminate属性の解説ページにリンク</title>
521- <link href="https://cpprefjp.github.io/lang/cpp11/attributes.html"/>
522- <id>b956b7708095b80da1c364a4d68cc66d65bde231:lang/cpp11/attributes.md</id>
523- <updated>2024-12-16T16:36:37+09:00</updated>
524-
525- <summary type="html"><pre><code>diff --git a/lang/cpp11/attributes.md b/lang/cpp11/attributes.md
526- index 1a15b8ba0..b48a93794 100644
527- --- a/lang/cpp11/attributes.md
528- +++ b/lang/cpp11/attributes.md
529- @@ -170,6 +170,7 @@ C++11で採用されたもの以外で検討された以下の機能は、属性
530- - [C++20 属性の名前空間を予約](/lang/cpp20/reserving_attribute_namespaces_for_future_use.md)
531- - [C++23 ラムダ式に対する属性](/lang/cpp23/attributes_on_lambda_expressions.md)
532- - [C++26 構造化束縛への属性を許可](/lang/cpp26/attributes_for_structured_bindings.md)
533- +- [C++26 未初期化変数の読み取りをエラー性動作とする (`[[indeterminate]]`属性)](/lang/cpp26/erroneous_behavior_for_uninitialized_reads.md)
534-
535-
536- ## 参照
537- </code></pre></summary>
538-
539- <author>
540- <name>Akira Takahashi</name>
541- <email>faithandbrave@gmail.com</email>
542- </author>
543- </entry>
544-
545- <entry>
546- <title>未初期化変数の読み取りをエラー性動作とする [P2795R5] -- C++11 属性構文 : indeterminate属性の解説ページにリンク</title>
547- <link href="https://cpprefjp.github.io/lang/cpp26/erroneous_behavior_for_uninitialized_reads.html"/>
548- <id>b956b7708095b80da1c364a4d68cc66d65bde231:lang/cpp26/erroneous_behavior_for_uninitialized_reads.md</id>
549- <updated>2024-12-16T16:36:37+09:00</updated>
550-
551- <summary type="html"><pre><code>diff --git a/lang/cpp26/erroneous_behavior_for_uninitialized_reads.md b/lang/cpp26/erroneous_behavior_for_uninitialized_reads.md
552- index 79b80c7ac..4f118a77d 100644
553- --- a/lang/cpp26/erroneous_behavior_for_uninitialized_reads.md
554- +++ b/lang/cpp26/erroneous_behavior_for_uninitialized_reads.md
555- @@ -137,5 +137,8 @@ int main() {
556- | 契約違反 | 契約に関する現在の策定作業では、契約違反時になにが起こるべきかという問題に直面している。エラー性動作という概念は有用な回答を与えてくれる可能性がある |
557-
558-
559- +## 関連項目
560- +- [C++11 属性構文](/lang/cpp11/attributes.md)
561- +
562- ## 参照
563- - [P2795R5 Erroneous behaviour for uninitialized reads](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2795r5.html)
564- </code></pre></summary>
565-
566- <author>
567- <name>Akira Takahashi</name>
568- <email>faithandbrave@gmail.com</email>
569- </author>
570- </entry>
571-
572614</feed>
0 commit comments