So can unique_ptr be used safely in stl collections?

后端 未结 3 446
南笙
南笙 2020-11-29 01:33

I am confused with unique_ptr and rvalue move philosophy.

Let\'s say we have two collections:

std::vector> autoCollect         


        
3条回答
  •  无人及你
    2020-11-29 01:58

    The unique_ptrs are being moved using their move constructor. unique_ptr is Movable, but not CopyConstructable.

    There's a great article on rvalue references here. If you haven't read about them yet, or are confused, take a look!

提交回复
热议问题