fastest way to convert a std::vector to another std::vector

后端 未结 8 2397
春和景丽
春和景丽 2020-12-03 14:08

What is the fastest way (if there is any other) to convert a std::vector from one datatype to another (with the idea to save space)? For example:

std::vector         


        
8条回答
  •  伪装坚强ぢ
    2020-12-03 14:17

    Copying element by element is not highly inefficient. std::vector provides constant access time to any of its elements, hence the operation will be O(n) overall. You will not notice it.

提交回复
热议问题