boost variant copy semantics
I was wondering what the copy semantics of boost variants are. I've checked the source code and it's a bit baffling to me so I was wondering, in the example code, if my getVal(name) function makes a copy of the underlying vector when it's returned? If so, should I change it to be a reference (&) returned instead? using Val = boost::variant<std::vector<int>, std::vector<std::string>>; Val getVal(std::string& name) { return map[name];// where map is std::map<std::string, Val> } Yes, your getVal returns a copy of the whole vectors (including copies of all the element strings, e.g.). Yes,