gpt4 book ai didi

c++ - 无法使用 boost::filesystem 创建路径

转载 作者:行者123 更新时间:2023-11-30 04:29:21 25 4
gpt4 key购买 nike

我正在尝试从另一条路径创建一条路径:

path;//this is somewhere else correctly created path from a string

但是当我尝试这个时:

boost::filesystem3::path project_path(path.begin(),path.end());  

我收到一个错误:

error: no matching function for call to 'convert(const   
boost::filesystem3::path*, const boost::filesystem3::path*,
boost::filesystem3::path::string_type&, const codecvt_type&)'

谁知道这是怎么回事?

编辑

auto beg_ = path.begin();
auto end_ = path.end() - 1;//this line causes no advance defined error.
// If I try to do:
boost::filesystem3::path some_path(path.begin(),path.end() - 1); I'm getting the before mentioned (original error).

我在任何地方都没有自己定义任何宏。

最佳答案

听起来 pathboost::filesystem3::path 类型而不是 std::string。 Boost 中的构造函数很可能被调用

template <class InputIterator>
path(InputIterator begin, InputIterator end)
{
if (begin != end)
{
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
s(begin, end);
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
}
}

如果我没记错的话,InputIterator 被解释为 boost::filesystem3::path*。如果是这种情况,那么是的,对 path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt()) 的调用可能不会匹配 path_traits::convert()

的任何现有方法签名

看看对 path 变量使用 std::string 是否有效——像这样

std::string somePath = "/some/path";

boost::filesystem3::path project_path(somePath.begin(), somePath.end());

虽然如果你要那样做,直接做会更容易

boost::filesystem3::path(somePath);

关于c++ - 无法使用 boost::filesystem 创建路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9418105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com