2

我刚刚遇到以下std::filesystem::path使用 Visual Studio 16.0.0 编译的行为,我想知道它是否正确。

#include <filesystem>

int main()
{
    std::filesystem::path absPath1("c:\\foo\\bar");
    std::filesystem::path absPath2("c:/foo/bar");

    bool absPathsAreEqual = absPath1 == absPath2; // absPathsAreEqual is true as expected.

    std::filesystem::path uncPath1("\\\\foo\\bar");
    std::filesystem::path uncPath2("//foo/bar");

    bool uncPathsAreEqual = uncPath1 == uncPath2; // uncPathsAreEqual is false which is a surprise for me.
}

我不是路径专家,所以我不确定在第二种情况下路径不相等是否有意义。那么这是正确的行为吗?

4

0 回答 0