File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
reference/memory/unique_ptr Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -84,9 +84,9 @@ int main()
8484
8585 // (2) 変換可能な型からの所有権移動
8686 // p1の所有権をp2に譲渡する
87- std::unique_ptr<void > p2;
87+ std::unique_ptr<const int > p2;
8888 p2 = std::move(p1);
89- assert (* static_cast<int* >(p2.get()) == 3);
89+ assert (* static_cast<const int* >(p2.get()) == 3);
9090
9191 // (3) リソース解放
9292 std::unique_ptr<int > p3(new int(3));
Original file line number Diff line number Diff line change @@ -143,8 +143,8 @@ int main()
143143 assert (!p6);
144144
145145 // (7) 変換可能な他のunique_ptrから所有権を譲渡する
146- std::unique_ptr<void > p7 = std::move(p5);
147- assert (* static_cast<int* >(p7.get()) == 3);
146+ std::unique_ptr<const int > p7 = std::move(p5);
147+ assert (* static_cast<const int* >(p7.get()) == 3);
148148}
149149```
150150* std::default_delete[ link /reference/memory/default_delete.md]
You can’t perform that action at this time.
0 commit comments