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));
種類:
アーティストとアルバムは std::string 型です this->find_diff は int を返します this->m_input_path は std::string です paths_iterator は std::vector(open bracket)boost::filesystem::path>::iterator 型です
コンパイル エラーが発生します。
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
このコードは、lame.exe を使用してファイルを mp3 に変換するバッチ スクリプトを出力するプログラムの一部です。これが設計されている音楽ライブラリの形式は次のとおりです。
ルート/アーティスト/曲
また
ルート/アーティスト/アルバム/曲
this->m_input_path はルートへのパスです。
問題に適切に取り組んでいるかどうかはわかりません。もしそうなら、私が得ているエラーをどのように修正しますか?
編集:
私のコードは次のとおりです。
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