Object delete itself from container

后端 未结 4 938
耶瑟儿~
耶瑟儿~ 2021-01-16 15:59

So I have a container(any kind, probably std::map or std::vector) which contains objects of a class with some network thing running in a thread that checks if it is still co

4条回答
  •  粉色の甜心
    2021-01-16 16:36

    STL containers tend to assume they're storing values; objects that can be copied and where copies are identical. Typically, objects which have threads fit poorly into that model. They have a much stronger sense of identity. In this case, you definitely have indentity - a copy of the object in a container is distinct from a copy outside.

提交回复
热议问题