在以下两种情况下,是否有理由调用lexically_normal:
std::filesystem::path filepath = someFuntionThatGetsAPath();
filepath = std::filesystem::canonical (filepath).lexically_normal ();
filepath = std::filesystem::weakly_canonical (filepath).lexically_normal ();
我在代码库中看到了这一点,但不确定是否有必要。我假设规范和弱规范不会失败,并且已经返回规范化路径。谢谢
最佳答案
从weakly_canonical的引用中:
... The resulting path is in normal form.
因此,在此函数的返回值上调用
lexically_normal
是没有意义的。但是,对于
canonical
,结果路径不一定是正常形式,因此在结果上调用lexically_normal
是有意义的。
关于c++ - 在对std::filesystem::canonical()或std::filesystem::weakly_canonical()的调用上,lexically_normal()是否冗余?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64063869/