istream
을 boost
의 progress_display
으로 바꿔서 boost::iterator_adaptor
을 사용하려고합니다. 내가 쓴 것은unformatative error using boost :: iterator_adaptor
class ifstreamWithProgress: public boost::iterator_adaptor <
ifstreamWithProgress,
char*,
boost::use_default,
boost::forward_traversal_tag > {
public:
// ifstreamWithProgress(const char* fname_) {}
ifstreamWithProgress(): iter(std::istream_iterator<char>()), pd(0)
{}
ifstreamWithProgress(const std::string& fname_): fname(fname_), fsize(0), pd(fsize) {
std::ifstream file(fname.c_str(), std::ios::binary);
fsize = file.tellg();
file.seekg(0, std::ios::end);
fsize = file.tellg() - fsize;
file.seekg(0, std::ios::beg);
iter = std::istream_iterator<char>(file);
pd.restart(fsize);
}
~ifstreamWithProgress() {
while(++pd < fsize);
}
const std::istream_iterator<char> getRawIstream() const {
return iter;
}
private:
std::string fname;
friend class boost::iterator_core_access;
std::istream_iterator<char> iter;
std::streampos fsize;
progress_display pd;
void increments() {
iter++;
++pd;
}
bool equal(const ifstreamWithProgress& rhs) const {
return this->iter == rhs.getRawIstream();
}
};
이 컴파일됩니다. 그러나 내가 뭔가를하기 시작했을 때
ifstreamWithProgress is("data.txt");
ifstreamWithProgress eos;
is != eos;
나는 그것이 복사 할 수 없다는 것을 말하는 컴파일 타임 오류가 난다. 디스플레이 클래스가 boost::noncopyable
에서 파생 되었기 때문에 이는 약간의 의미가 있습니다. 그러나 내가 얻지 못하는 것은 복사가 일어나는 곳입니다. 어떤 포인터?
추신 : 오류 메시지가 소스 어디를 가리 키지 않습니다
1>c:\users\leon.sit\documents\myprojects\c++\general_models\phoenixdsm\phx\fileProgressBarWrapper.hpp(58) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable'
1> C:\Program Files\boost\boost_1_44\boost/noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable'
1> C:\Program Files\boost\boost_1_44\boost/noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable'
1> This diagnostic occurred in the compiler generated function 'ifstreamWithProgress::ifstreamWithProgress(const ifstreamWithProgress &)'
입니다. 그러나 비교 선을 주석 처리 한 후에 컴파일됩니다.
악마가 컴파일러 오류로 세부 사항에 있기 때문에 정확한 오류 메시지와 함께 오류를 생성하는 정확한 코드 ('무언가'와 같지 않음)를 게시해야합니다. 이상적으로는 둘 모두 복사하여 붙여 넣어야합니다. –