path::mkdir(std::string{}) fails. A test pins that it does — an empty path must not be folded into the "already exists" success case — but no page or comment states it, so the only place the behaviour is written down is the test.
The reason it was left out until now is that the outcome rests on what std::filesystem::create_directories puts in the error_code for an empty path, which the standard does not specify. Measuring it under one standard library was not enough to write it as a contract.
That has changed: the suite now runs under libstdc++ and libc++ on Linux, and under Apple's libc++ on macOS, and the test passes on all of them. Two independent implementations agree that the call fails.
What can be written is the intent, not the mechanism — that an empty path is not accepted as an existing directory and comes back as a failure — without naming a specific errc, which is still implementation-defined.
path::mkdir(std::string{})fails. A test pins that it does — an empty path must not be folded into the "already exists" success case — but no page or comment states it, so the only place the behaviour is written down is the test.The reason it was left out until now is that the outcome rests on what
std::filesystem::create_directoriesputs in theerror_codefor an empty path, which the standard does not specify. Measuring it under one standard library was not enough to write it as a contract.That has changed: the suite now runs under libstdc++ and libc++ on Linux, and under Apple's libc++ on macOS, and the test passes on all of them. Two independent implementations agree that the call fails.
What can be written is the intent, not the mechanism — that an empty path is not accepted as an existing directory and comes back as a failure — without naming a specific
errc, which is still implementation-defined.