第1年1月7日 unique_ptr

1.

void foo(std::unique_ptr<Entity>) {
  puts("Entering foo");
  puts("Leaving foo");
}
 
void ex2() {
  puts("--------");
  puts("Entering ex2");
  auto e1 = std::make_unique<Entity>();  
  foo(std::move(e1));
  // e1 was destoried.
  puts("Leaving ex2");
}

 

 

https://www.bilibili.com/video/BV1fK411H7CA/?spm_id_from=333.788.recommend_more_video.3

https://zxi.mytechroad.com/blog/c/cpp-11-smart-pointers/

posted @ 2021-01-07 19:04  lianhuaren  阅读(56)  评论(0编辑  收藏  举报