configuration: make AbsolutePath a wrapper type#15362
Open
amaanq wants to merge 1 commit intoNixOS:masterfrom
Open
configuration: make AbsolutePath a wrapper type#15362amaanq wants to merge 1 commit intoNixOS:masterfrom
AbsolutePath a wrapper type#15362amaanq wants to merge 1 commit intoNixOS:masterfrom
Conversation
xokdvium
reviewed
Feb 27, 2026
| * rejecting empty and relative paths. | ||
| */ | ||
| struct AbsolutePath : std::filesystem::path | ||
| struct AbsolutePath |
Contributor
There was a problem hiding this comment.
Can be done using private inheritance, no? Less churny code to write, just using path::operator== and stuff.
Member
Author
There was a problem hiding this comment.
Hm I tried this, and it looks like we'd still have churn because we can't just do using path::operator== and friends because they are defined as non-member friend functions
Public inheritance from `std::filesystem::path` lets `AbsolutePath` silently slice down to a plain path when passed by value, so this commit changes `AbsolutePath` to use a `path` field instead, which is easier to reason about and prevents that.
906aabb to
029f54c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Public inheritance from
std::filesystem::pathletsAbsolutePathsilently slice down to a plain path when passed by value, so this commit changes
AbsolutePathto use apathfield instead, which is easier to reason about and prevents that.Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.