为什么 boost::filesystem::path 和 std::filesystem::path 的路径转义字符不同?

Why path escape character is different for boost::filesystem::path and std::filesystem::path?

boost::filesystem::path 使用 & 转义路径字符串中的引号,see demo:

std::cout << boost::filesystem::path("/R&D/Project \"boost\"") << std::endl;

打印 "/R&&D/Project &"boost&""。但是,对于 std::filesystem::path I see this:

Performs stream input or output on the path p. std::quoted is used so that spaces are not truncation when later read by stream input operator.

这里来自 std::quoted:

escape - the character to use as the escape character, defaults to \

由此我可以看出 std::filesystem::path 将使用 \ 而不是 &

这是正确的吗?如果是,为什么委员会决定改变这种行为?

额外的问题:是否有可用的 std::filesystem::path 实现?好像最新的 GCC 和 clang 的 none 提供了 <filesystem> header.

Boost::Filesystem 相当古老,早于 C++14 的 quoted。标准内部一致是完全合理的。关注 Boost 只是次要问题。

If yes, why the committee decided to change this behavior?

来自N3399,强调的是我的:

The Boost inserter outputs quoted strings, which are recognized as such by the extractor. There is a sentiment within the Filesystem Study Group that supplying a quoted and/or escaped string manipulator as a string extension would be a better solution than a path specific feature. See proposal N3431, Quoted Strings Library Proposal.

也就是说,文件系统研究小组认为使用 quoted 字符串操纵器比 path

的特定功能更好

Bonus question: are there any implementations of std::filesystem::path available? Seems like none of latest GCC and clang provide header.

AFAIK,g++、clang、msvc 等主要编译器都提供 filesystem 作为实验性功能,在命名空间 std::experimental::filesystem 中提供 <experimental/filesystem>。如你所见,gcc 从 5.3 版开始有它 ,MSVC 从 VS2012 开始有它(它在 VS2012 和 VS2013 中是 <filesystem>,然后在 VS2015 中移动到 <experimental/filesystem><filesystem>