ブーストファイルシステムコンパイルエラー
-
20-09-2019 - |
質問
ブーストファイルシステムライブラリを利用するコードをいくつか書いています。これが私のコードの抜粋です:
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
コンパイルエラーが発生します:
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
解決
Basic_Path :: Iteratorは双方向のイテレーターです。したがって、-1と-2の算術は許可されていません。オペレーター +および - イテレーターと整数値の間で、ランダムアクセシテーターに対して定義されます。
.end()-1を使用する代わりに、使用することに頼ることができます。
他のヒント
あなたの新しいエラーはあなたのことを示しています end_path_iter
十分な要素がありません(それが「減少する必要があります 過去 begin "?)、つまり、あなたの道はあなたが予想よりも短いです。
所属していません StackOverflow