回答編集履歴
2
書式の改善
answer
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
> abcの前にデストラクタが二回呼び起こされている理由
|
2
2
|
|
3
|
-
[return 文 - cppreference.com](https://ja.cppreference.com/w/cpp/language/return)より
|
3
|
+
[return 文 - cppreference.com](https://ja.cppreference.com/w/cpp/language/return)より
|
4
4
|
|
5
5
|
|
6
6
|
> `return` 文なしに値を返す関数 (`main` を除く) の終わりに達した場合、動作は未定義です。
|
7
7
|
|
8
|
-
|
8
|
+
とのことです。実際の動作としては、皆さんの回答のようになっていると考えられます。
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
|
-
また、C++17 以降
|
12
|
+
(また、C++17 以降でも NRVO は保証されないようです。)
|
13
13
|
|
14
|
-
参考 -> [値のコピー省略を保証 - cpprefjp C++日本語リファレンス](https://cpprefjp.github.io/lang/cpp17/guaranteed_copy_elision.html)
|
14
|
+
(参考 -> [値のコピー省略を保証 - cpprefjp C++日本語リファレンス](https://cpprefjp.github.io/lang/cpp17/guaranteed_copy_elision.html))
|
1
書式の改善
answer
CHANGED
@@ -9,6 +9,6 @@
|
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
|
-
また、C++17 以降に保証されるのは RVO だけで、NRVO は保証され
|
12
|
+
また、C++17 以降に保証されるのは RVO だけで、NRVO は保証されないことに注意してください。
|
13
13
|
|
14
14
|
参考 -> [値のコピー省略を保証 - cpprefjp C++日本語リファレンス](https://cpprefjp.github.io/lang/cpp17/guaranteed_copy_elision.html)
|