Which string classes to use in C++?

后端 未结 7 2144
遇见更好的自我
遇见更好的自我 2021-02-02 14:30

we have a multi-threaded desktop application in C++ (MFC). Currently developers use either CString or std::string, probably depending on their mood. So we\'d like to choose a s

7条回答
  •  失恋的感觉
    2021-02-02 14:48

    I say always go for std::string. As mentioned, RVO and NVRO will make returning by copies cheap, and when you do end up switching to C++0x eventually, you get a nice performance boost from move semantics, without doing anything. If you want to take any code and use it in a non-ATL/MFC project, you can't use CString, but std::string will be there, so you'll have a much easier time. Finally, you mentioned in a comment you use STL containers instead of MFC containers (good move). Why not stay consistent and use STL string too?

提交回复
热议问题