Why is std::filesystem::u8path deprecated in c++20?

删除回忆录丶 提交于 2019-12-12 09:31:50

问题


Introduced in c++17, std::filesystem::u8path seems to be deprecated in c++20.

What is the reason for this choice? What should I use in c++17? What should I use in c++20?


回答1:


Because, thanks to the existence of the C++20 feature char8_t, this will work:

path p(u8"A/utf8/path");

u8path existed to allow the detection of the difference between a UTF-8 string and a narrow character string. But since C++20 will give us an actual type for that, it is no longer necessary.


What should I use in c++17?

Use u8path. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal.

At present, in C++20 u8path(u8"A/UTF8/String") will fail to compile in C++20 due to u8 now creating a char8_t string. But C++20 may be getting a change to u8path that takes char8_t strings.



来源:https://stackoverflow.com/questions/54004000/why-is-stdfilesystemu8path-deprecated-in-c20

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!