Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support both generic and native format of std::filesystem::path #3715

Closed
zhihaoy opened this issue Nov 13, 2023 · 1 comment · Fixed by #3729
Closed

Support both generic and native format of std::filesystem::path #3715

zhihaoy opened this issue Nov 13, 2023 · 1 comment · Fixed by #3729

Comments

@zhihaoy
Copy link

zhihaoy commented Nov 13, 2023

Why

Need a way to include the paths with only slashes rather than backslashes in the output in a cross-platform manner. This can be done by introducing type in format-spec for path.

How to use the proposed feature

On Windows,

std::filesystem::path filename = R"(C:\Users\zhihaoy\.cache)";
print("|{}|", filename);  // prints |C:\Users\zhihaoy\.cache|
print("|{:n}|", filename);  // prints `.native()` |C:\Users\zhihaoy\.cache|
print("|{:g}|", filename);  // prints `.generic_wstring()` |C:/Users/zhihaoy/.cache|

On POSIX, the last line prints .generic_string().

@vitaut
Copy link
Contributor

vitaut commented Nov 17, 2023

Sounds reasonable. A PR would be welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants