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

Add FilesystemPath string conversion operator #1286

Merged
merged 5 commits into from
Mar 12, 2025

Conversation

DanRStevens
Copy link
Collaborator

@DanRStevens DanRStevens commented Mar 12, 2025

For debugging purposes it's convenient have to have FilesystemPath easily convert to a std::string.

It also helps to have concatenation operations with string literals.

This conversion operator existed previously, though was not marked as explicit.

I was tempted to remove the string() method when this was added. One reason to keep it is the std::filesystem::path class has a string() method, so it makes the two types more compatible. For a program using auto, it may be possible to switch between them for simple cases.

Related:

This time mark it as `explicit`.
The `<filesystem>` api expects `std::filesystem::path` objects. These can be implicitly constructed from `std::string`. They can not be implicitly constructed by something that implicitly converts to `std::string`. Hence we always need to be explicit with these calls.
This makes it much easier to build error messages that display a path.
@DanRStevens DanRStevens merged commit 9238ffe into main Mar 12, 2025
8 checks passed
@DanRStevens DanRStevens deleted the filesystemPathStringConvert branch March 12, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant