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

时间:2011-03-21 07:08:31

标签: c++ string boost std

我有代码:

std::string firstFile = boost::filesystem::path(first->name()).leaf();

但是得到错误:

error conversion from ‘boost::filesystem3::path’ to non-scalar type ‘std::string

我该如何解决?

谢谢。

1 个答案:

答案 0 :(得分:10)

std::string firstFile = boost::filesystem::path(first->name()).leaf().string();

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