C++17 文件路径分解为文件夹名称

C++17 file path decomposition into folder names

我正在研究 c++17 的规范 filesystem 试图找到从给定路径中所有文件夹名称的分解中获取向量的函数,但找不到任何函数。是什么原因?对我来说似乎是基本功能。

因为不需要在文件系统中。 filesystem::path 只公开迭代器,其余的由 vector 的构造函数完成:

#include <vector>
#include <filesystem>
#include <iostream>

using path = std::experimental::filesystem::path;
path p("C:/RootDir/SubDirectory/SubSubDirectory/SomeFile.txt");

int main() {
    std::vector<path::iterator::value_type> v(p.begin(), p.end());

    for( auto itr = v.begin(); itr != v.end(); ++itr)
    {
        std::cout << *itr << std::endl;
    }
}