假设有
boost::variant<int, std::string> v;
如何获得类型为 std::string &
的引用 x
可以像这样使用
x = "abc";
并且会有等同于
的行为v = "abc";
?
最佳答案
std::string& x = boost::get<std::string>(v);
关于c++ - boost 变体 : get reference to the variant by its type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33227003/