Open jwakely opened 8 years ago
Overloads for const basic_string
added in 252903978b37cf90a0feec78cd85143f23da23da.
Leaving open for further discussion.
Leaving it open is good; I have some ideas about string_view/string interoperability that I'm hoping to circulate in Kona.
There is something about buffers in general that is bothering me (amplified by the addition of dynamic_buffer.)
While I recognized the need for the DynamicBuffer concept, and in fact find that it can be useful in other contexts, I am bothered by the fact that I need to wrap my containers in this or that buffer before passing it to an operation. For instance, I currently need to do
std::string content;
socket.read(net::dynamic_buffer(content));
whereas I would much rather be able to do this:
std::string content;
socket.read(content);
This could be done by adding a trait (or policy) to wrap the buffer, and then have specializations for std::string, std::string_view, std::vector, etc. The implementation of socket::read() could then use the trait to find the appropriate buffer type.
If the trait is made public, then we could have support for user-defined buffers as well.
For inspiration, I have an example of such a trait for a parser/generator project, where the trait
This fails because the
buffer(basic_string_view<C,T>)
overload cannot deduce its template arguments.We could add overloads for
string_view
,wstring_view
,u16string_view
andu32string_view
but that's not helpful for generic code using unusual specializations ofbasic_string
.Probably better to add overloads for
const basic_string