Consider the following program:
// See godbolt link #include <assert.h> #include <string> #include <filesystem> using namespace std; using namespace std::filesystem; int main() { bool b = L"a//b" == std::string("a/b"); assert(b); // passes. What?! return b; }
L"a" gets converted into a path, and the string gets converted into a path, and then those paths are compared for equality. But path equality comparison doesn't work anything like string equality comparison, leading to surprises.
path's other operators should be made hidden friends as well, so that one side or the other of a given operator is of type path before those conversions apply.