On 14/10/2021 14:28, Vinnie Falco wrote:
Thinking out loud here, it seems that the segments container models the path as
vector< string >
When it actually needs to model the container as
struct { bool leading_slash; vector< string > };
Should I just add this function
void segments::set_absolute( bool path_should_be_absolute );
and keep
bool segments::is_absolute() const noexcept;
?
I guess the answer to that depends on how you want clear-and-multiple-push_back to behave. Does that preserve or alter absoluteness of the path? Most of my experience with manipulating URIs (other than just using hard-coded strings) is via the .NET Uri class, and FWIW with those: 1. Instances are immutable; the only way to get a new Uri is to parse a new one from scratch or resolve a relative one from a base. (Both the base and the 'relative' can actually be either absolute or relative.) 2. Its 'Segments' property does include trailing slashes in the components -- so { "/", "foo/", "bar/", "index.html" } and is also read-only. (And also doesn't support relative URIs, though I don't know why not as they wouldn't be ambiguous.) I'm not saying these are necessarily good choices for your implementation as well; just as a point of comparison.