Convert a std::vector of a boost::variant type
问题 How might I implement the function below to convert from vector of Value to a Container ? I wish to assert if not all the members of values are of the same type, i.e. if the vector contains a mix of strings and ints. This is because the function's return value is either a std::vector<int> or a std::vector<std::string> . typedef boost::variant<int, std::string> Value; typedef boost::variant<std::vector<int>, std::vector<std::string> > Container; Container valuesToContainer(const std::vector