我希望实现类似的目标
if (basePath.contains(subPath)) {
    // subPath is a subPath of the basePath
}
我知道我可以通过遍历 的父母并在途中subPath检查来实现这一点。basePath
有没有std办法呢?
std::filesystem::path("/a/b/").contains("/a/b/c/d") == true
您可以迭代两个路径中的项目:
for (auto b = basePath.begin(), s = subPath.begin(); b != basePath.end(); ++b, ++s)
{
    if (s == subPath.end() || *s != *b)
    {
        return false;
    }
}
return true;
| 归档时间: | 
 | 
| 查看次数: | 3659 次 | 
| 最近记录: |