Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于:
typedef boost::variant<std::vector<int8>, std::vector<std::string> > Container;
如何初始化c为单列?
c
std::vector<std::string> v = boost::assign::list_of<std::string>("stringValue"); Container c(v);
应该这样做 - 将 list_of 结果显式转换为您希望变体存储的类型:
Container c(vector<string>(list_of<string>("stringValue")));
甚至更好 - 使用 C++11:
Container c{ vector<string> {"stringValue1", "stringValue2"}};