“CopyConstructible” requirement for C++ stl container element

后端 未结 6 1151
后悔当初
后悔当初 2021-01-04 22:05

Regarding to the requirement for C++ stl container element, the standard says: the element type should be CopyConstructible, and there is a table for CopyConstructible requi

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 22:35

    Deep or shallow copy both work. For instance, shared_ptr always does a shallow copy (with some extra reference counting stuff), and you can use them in containers just fine. It depends on the semantics of copy-operation.

    Equivalent means your program should not depend on whether it works with the original or with the copy.

提交回复
热议问题