Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 316
Guillaume Gris Avatar asked Jan 02 '19 09:01

Guillaume Gris


People also ask

What is u8path in c++20?

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.

What is the syntax for the path name of a directory?

The path name has the following syntax: 1 root-name(optional): identifies the root on a filesystem with multiple roots (such as "C:" or "//myserver" ). In case of... 2 root-directory(optional): a directory separator that, if present, marks this path as absolute. If it is missing (and the... 3 Zero or more of the following: More ...

When is a generic pathname treated as a directory path?

On those OS where native format differs between pathnames of directories and pathnames of files, a generic pathname is treated as a directory path if it ends on a directory separator and a regular file otherwise.

What does deprecation of a path mean?

Use u8path. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.


1 Answers

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.

like image 94
Nicol Bolas Avatar answered Oct 06 '22 05:10

Nicol Bolas