Is std::array movable?

前端 未结 1 480
刺人心
刺人心 2020-12-05 02:17

Is std::array movable?

In Bjarne Native 2012 presentation slides (slide 41) it lists std::array as one of the only containers that isn\

相关标签:
1条回答
  • 2020-12-05 02:52

    std::array is movable only if its contained objects are movable.

    std::array is quite different from the other containers because the container object contains the storage, not just pointers into the heap. Moving a std::vector only copies some pointers, and the contained objects are none the wiser.

    Yes, std::array uses the default move constructor and assignment operator. As an aggregate class, it's not allowed to define any constructors.

    0 讨论(0)
提交回复
热议问题