Creating a list of objects containing std::atomic

非 Y 不嫁゛ 提交于 2019-12-11 06:02:15

问题


I have a list of objects stored in a list that represent chunks of read-only memory for threads to use. each chunk object has an atomic that acts as a reference count, pretty simple.

I have a problem though, std::list<Type> apparently needs a copy constructor for Type?, and having an std::atomic as a member of Type deletes the default copy constructor of the chunk object's class. I'm pretty sure a list isn't allowed to copy or move it's elements around whatsoever in memory, so why would it require that constructor?

Anywho, the question, how might I have a list of objects containing std::atomic? The atomic cannot change address, I have no interest in copying or moving it, so it seems I need to use something other than std::list?

来源:https://stackoverflow.com/questions/53963721/creating-a-list-of-objects-containing-stdatomic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!