How to create a container of noncopyable elements

后端 未结 3 1940
梦谈多话
梦谈多话 2021-01-18 11:44

Is there a way use STL containters with non-copyable elements?

something like this:

class noncopyable
{
    noncopyable(noncopyable&);
    const          


        
3条回答
  •  醉酒成梦
    2021-01-18 12:22

    No, non-copyable elements can't be in C++ container classes.

    According to the standard, 23.1 paragraph 3, "The type of objects stored in these components must met the requirements of CopyConstructible types (20.1.3), and the additional requirements of Assignable types."

提交回复
热议问题