如何使用Boost.Filesystem更改当前路径

Adr*_*ian 14 c++ boost

启动程序时,我想使用current_path()("C:\ workspace\projects")打印当前路径.然后我希望能够改变路径,让我们说"c:\ program files",所以当我再次打印current_path()时,我想要打印"c:\ program files".像这样的东西

int main()
{
   cout << current_path() << endl;  // c:\workspace\projects
   aFunctionToChangePath("c:\program files");
   cout << current_path() << endl;  // c:\program files
}
Run Code Online (Sandbox Code Playgroud)

库中是否有我失踪的功能,所以我可以实现这个功能?

ybu*_*ill 20

int main()
{
   cout << current_path() << '\n'; // c:\workspace\projects
   current_path("c:\\program files");
   cout << current_path() << '\n';  // c:\program files
}
Run Code Online (Sandbox Code Playgroud)