Is it correct that std::filesystem::operator==() returns false when comparing two unc paths with different path separators?

Viewed 202

I just fell over the following behavior of std::filesystem::path compiling with Visual Studio 16.0.0 and I wonder if it is correct.

#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.
}

I am no path expert so I am not sure if it makes sense that the paths are not equal in the second case. So is this the correct behavior?

0 Answers
Related