C++的文件系统迭代器

uni*_*n83 4 c++ boost iterator stl directory-listing

我想要一个基本的C++ STL类文件系统容器.

例如

std::filesystem::const_iterator i = filesys.begin();  
i->file_name(); i->full_path(), 
Run Code Online (Sandbox Code Playgroud)

等等..

这样的事情存在吗?

Naw*_*waz 5

是.它存在.几乎相似,至少可以与STL迭代器和容器一起使用.

提高::文件系统

例:

path p ("directorypath");
std::vector<path> v;                      
std::copy(directory_iterator(p), directory_iterator(), std::back_inserter(v));
for (std::vector<path>::const_iterator it=v.begin(); it != v.end(); ++it)
{
     std::cout << "   " << *it << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

我想,现在你想看看directory_iterator它提供了什么.