Thread-safe vector: Is this implementation thread-safe?

前端 未结 7 1925
梦毁少年i
梦毁少年i 2021-01-16 13:22

I have a question regarding the term thread-safety. Let me give an example:

#include 
#include 

/// A thread-safe vector
class Th         


        
7条回答
  •  借酒劲吻你
    2021-01-16 14:10

    Yes, I would. Both public methods are protected by locks, and all the special member functions (copy/move constructor/assignment) are implicitly deleted because std::mutex is neither copyable nor movable.

提交回复
热议问题