std::string in struct - Copy/assignment issues?

前端 未结 4 808
甜味超标
甜味超标 2020-12-19 10:10

Suppose I have a struct containing a std::string, like this:

struct userdata{
        int uid;
        std::string username;
    }

Do I nee

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 11:02

    std::string is reference-counted, and its copy constructor takes place. So nothing to worry about. Everything is handled correctly.

提交回复
热议问题