c++ - 从 ‘boost::filesystem3::path’ 到非标量类型‘std::string’的 boost 错误转换

标签 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

我该如何解决?

谢谢。

最佳答案

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

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

关于c++ - 从 ‘boost::filesystem3::path’ 到非标量类型‘std::string’的 boost 错误转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5374754/

相关文章:

JavaScript 从联系人号码中删除空格、国家代码和乞求零

c - 搜索字符串

c - 如何通过空格 ""分隔符分割或标记字符串数组以查找每个字符串中的第二个单词

c++ - 如何向 Boost.Tuple 添加元素

c++ - 在模板类的 constexpr 函数中找到正确的宏常量

c++ - directx10 gpu 上的 DirectX11 程序

c++ - 如何在 Boost.Lambda 中使用 <cmath> 中的函数?

c++ - 无需其他变量即可替换值的程序

c++ - 使用 Boost Spirit 匹配字符串

c++ - 如何欺骗 boost::asio 以允许仅 move 处理程序