C++ Boost文件系统编译错误

C++ Boost文件系统编译错误,c++,boost,compiler-errors,std,boost-filesystem,C++,Boost,Compiler Errors,Std,Boost Filesystem,我正在编写一些利用boost文件系统库的代码。以下是我的代码摘录: artist = (this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) ? (*(paths_iterator->parent_path().end() - 1)) : (*(paths_iterator->parent_path().end() - 2)); album = (this->find_

我正在编写一些利用boost文件系统库的代码。以下是我的代码摘录:

artist = (this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) ? (*(paths_iterator->parent_path().end() - 1)) : (*(paths_iterator->parent_path().end() - 2));
album = (this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) ? "" : (*(paths_iterator->parent_path().end() - 1));
类型:

artist and album are of type std::string this->find_diff returns an int this->m_input_path is a std::string paths_iterator is of type std::vector(open bracket)boost::filesystem::path>::iterator
基本路径::迭代器是一个双向迭代器。因此,不允许使用-1和-2进行算术运算。迭代器和整数值之间的运算符+和-是为RandomAccessIterator定义的


您可以使用-,而不是使用.end-1。基本路径::迭代器是一种双向迭代器。因此,不允许使用-1和-2进行算术运算。迭代器和整数值之间的运算符+和-是为RandomAccessIterator定义的


不使用.end-1,您可以使用-。

您的新错误表明您的end\u-path\iter没有足够的元素应该从begin?开始递减,即您的路径比您预期的短。

您的新错误表明您的end\u-path\u-iter没有足够的元素应该从begin?开始递减?,也就是说,您的路径比您预期的要短。

您使用的是哪个版本的boost?您使用的是哪个版本的boost?啊,这就是问题所在,我不应该在路径迭代器->父路径.end;谢谢你的帮助。啊,这就是问题所在,我不应该在路径迭代器->父路径.end;谢谢你的帮助。
error C2039: 'advance' : is not a member of 'boost::filesystem::basic_path<String,Traits>::iterator'    d:\development\libraries\boost\boost\iterator\iterator_facade.hpp on line 546
    boost::filesystem::path::iterator end_path_itr = paths_iterator->parent_path().end();
    if(this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) /* For cases where: /root/artist/song */
    {
        album = "";
        end_path_itr--;
        artist = *end_path_itr;
    }
    else /* For cases where: /root/artist/album/song */
    {
        end_path_itr--;
        album = *end_path_itr;
        end_path_itr--; <-- Crash Here
        artist = *end_path_itr;
    }
Assertion failed: itr.m_pos && "basic_path::iterator decrement pat begin()", file ... boost\filesystem\path.hpp, line 1444