Which is correct: vector OR const vector?

后端 未结 1 1892
一整个雨季
一整个雨季 2021-01-18 08:49

Which is correct: vector OR const vector?

I want to create an std::vector of std::stri

1条回答
  •  庸人自扰
    2021-01-18 09:01

    If your only choices are those two and you want the program to compile, use const std::vector.

    If you don't mind compilation errors (both on GCC4.8 and Clang), probably due to the fact that const std::string does not meet the requirement of CopyAssignable (prior to C++11) or MoveAssignable (since C++11), even though, apparently, it's mostly because it's not Destructible, use std::vector.

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