I’m just starting to get into the C++ boost libraries. I’m running into an issue with directory_iterator and recursive_directory_iterator. When I try to compile the following code, I always get a no match for operator!=. I have also tried == to no avail.
const boost::filesystem::recursive_directory_iterator end();
for(boost::filesystem::recursive_directory_iterator i(p); i != end; i++){
if(boost::filesystem::is_regular_file(i->status())){
cout << i->path().filename() << endl;
}
}
Any help?
Thanks!
const boost::filesystem::recursive_directory_iterator end()does not define a variableendinstead it declares a function prototype for functionendwhich returns aconst boost::filesystem::recursive_directory_iteratorand does not take any arguments (Search for “C++ most vexing parse” to understand why this happens). Change it toconst boost::filesystem::recursive_directory_iterator end;.