On 23/08/2022 08:14, Vinnie Falco wrote:
Hmm yeah I see what you mean. I didn't think of this - that's why field experience is so vital. The reason they return url_base& is because that's the class that has all the mutation logic. This is shared between `url` and `static_url`. To get functions like `set_host` to return `url&` instead would be challenging. We would have to put a copy of the entire set of mutating API member function signatures into both `url` and `static_url_base` and have those return the correct type.
Another option (not necessarily a better one) is to make url_base (or whatever provides those methods, if moved) use CRTP. This could potentially even be just a thin wrapper around private implementation that still uses a concrete base internally, at the cost of a slightly dodgy downcast in the wrapper.