boost变量:按类型引用变量

pol*_*.ph 3 c++ boost variant

假设有

boost::variant<int, std::string> v;
Run Code Online (Sandbox Code Playgroud)

如何获得可以使用x的类型的引用std::string &

x = "abc";
Run Code Online (Sandbox Code Playgroud)

并且会有相当于的行为

v = "abc";
Run Code Online (Sandbox Code Playgroud)

Xia*_*Pei 5

std::string& x = boost::get<std::string>(v);