type requirements for std::vector

前端 未结 5 1458
夕颜
夕颜 2020-12-21 17:17

I am still confused about the requirements for a type to be used with a std::vector in C++11, but this may be caused by a buggy compiler (gcc 4.7.0). This code:

5条回答
  •  生来不讨喜
    2020-12-21 17:38

    In C++11, the requirements depend on the operations performed. In the case of std::vector::resize(), the requirement on T is that it be CopyInsertable into the vector.

    From §23.3.6.3

    void resize(size_type sz);

    ....

    Requires: T shall be CopyInsertable into *this.

提交回复
热议问题