P0083r3 for basic_fields
Version: 90
Just wanted to know if a "merge" API for header would make a sense or not. I have a situation where I need to have some sort of default set of headers which can either be customised by a client code by providing another header. So, instead of doing the regular (and inefficient) way of iterating and performing a "set", using the "merge" operation of intrusive list would be better.
WDYT ?
I don't understand what you're trying to do. Could you please provide a very simple piece of example code?
Yeah, I think a pseudo code would be good.
// Client side code
Request r;
beast::http::request_header<> h;
//...fill headers here
r.send(h);
OR
r.send({ {"e", "f"}, {"a", "z"} });
// Library code
class Request
{
public:
Request() {
fill_in_defaults();
}
void send(const std::initializer_list<std::pair<beast::string_view, beast::string_view>>&);
void send(const beast::http::request_header<>&);
private:
void fill_in_defaults() {
headers_.set("a", "b");
headers_.set("c", "d");
}
private:
beast::http::request_header<> headers_;
};
Assume that the send operation creates the complete request and dispatches it and it has 2 overloads, one taking an initializer-list and the other taking a beast header itself.
So, in the overload taking the beast::http::request_header, what would be the most efficient way to merge it with the headers_ member ? I would think the intrusive_list merge operation would be good to have in such cases.
Please let me know if there is anything I can add to make it more clear.
How would you feel about something like this: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0083r3.pdf
Example of use: http://en.cppreference.com/w/cpp/container/map/merge
Hmm..yes. That is a cool feature. But since beast is making use of boost::intrusive_list, the functionality is already there. Or are you planning to move to std::containers ?
I'm saying that http::basic_fields could offer the same feature as described in P0083r3. So you would have basic_fields::node_handle, basic_fields::extract(), and basic_fields::merge().
Oh..ok. That would be nice.