2009-12-21 8 views
1

부스트 파일 시스템 라이브러리를 사용하는 코드를 작성 중입니다.부스트 파일 시스템 컴파일 오류

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 
+0

어떤 버전의 부스트를 사용하고 있습니까? –

+0

Boost 1.41.0 - 15char –

답변

3

basic_path :: 반복자는 양방향 반복자입니다. 따라서 -1과 -2의 산술 연산은 허용되지 않습니다. 반복자와 정수 값 사이의 연산자 +와 -는 RandomAccessIterator에 대해 정의됩니다.

.end() - 1을 사용하는 대신 -을 사용할 수 있습니다.

1

새 오류는 end_path_iter (즉? "감소 과거 시작"이어야 함), 즉 경로가 예상보다 짧은 충분한 요소를 가지고 있지 않음을 나타냅니다.

+0

아, 그게 문제입니다. paths_iterator-> parent_path(). end();에서 parent_path를 사용해서는 안됩니다. 당신의 도움을 주셔서 감사합니다. –

관련 문제