提升从'boost :: filesystem3 :: path'到非标量类型'std :: string的错误转换

0xA*_*xAX 6 c++ string boost std

我有代码:

std::string firstFile = boost::filesystem::path(first->name()).leaf();
Run Code Online (Sandbox Code Playgroud)

但得到错误:

error conversion from ‘boost::filesystem3::path’ to non-scalar type ‘std::string
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

谢谢.

ybu*_*ill 10

std::string firstFile = boost::filesystem::path(first->name()).leaf().string();
Run Code Online (Sandbox Code Playgroud)

另请注意,该leaf函数已弃用,并在Boost.Filesystem V3中删除.