stl container of references C++11

前端 未结 4 725
感动是毒
感动是毒 2020-12-18 10:32

I know this question was asked a million of times. And most of answers just says that object should be CopyAssignable and CopyConstructible. But documentation clearly says t

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-18 11:00

    § 23.2.1 [container.requirements.general] ¶ 1 of N4140 says (emphasis mine):

    Containers are objects that store other objects. They control allocation and deallocation of these objects through constructors, destructors, insert and erase operations.

    But a reference is not an object so you cannot put it into a standard library container.

提交回复
热议问题