Skip to content

Commit eb5bc29

Browse files
committed
fix samples. unique_ptr with void is ill-formed
1 parent b66dc23 commit eb5bc29

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

reference/memory/unique_ptr/op_assign.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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));

reference/memory/unique_ptr/op_constructor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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]

0 commit comments

Comments
 (0)