GithubHelp home page GithubHelp logo

Comments (6)

vinniefalco avatar vinniefalco commented on August 16, 2024

This would be a nice example

from url.

vinniefalco avatar vinniefalco commented on August 16, 2024

If we do this in the library it would be something like

subrange params_encoded_view::find_all( string_view key );

from url.

vinniefalco avatar vinniefalco commented on August 16, 2024

It would be nice to have an API that make possible to return all values associated with a key in a list/container

I don't think the library should provide this explicitly. Instead, with the proposed find_all above, you could use std::back_insert_iterator (C++11) or one of the new fancy range algorithms to fill in the container of your choosing, even supporting custom allocators.

from url.

vinniefalco avatar vinniefalco commented on August 16, 2024

boost.http.proto supports this:
https://github.com/CPPAlliance/http_proto/blob/dc92ac4e05ad8b1b4b60ec8924b2f0cfa1167598/include/boost/http_proto/fields_view.hpp#L243

from url.

alandefreitas avatar alandefreitas commented on August 16, 2024

Cons:

  1. It would be like emulating map::equal_range to a container where equal keys are not in order. We also have unordered_map::equal_range but the equal keys are also in sequence in these containers.
  2. To emulate something that's not there, we would need a view that would be a lot like ranges::views::filter and pretend this is native. This would need a reasonable API, etc... which could involve a lot of work to get right.
  3. There are many possible designs for the API, like a std::back_insert_iterator. Each design would serve only a subset of users.
  4. Doing that implicitly might indicate to the user this happens in constant time, like some kind of weird vector::push_front would.
  5. This is useful for avoiding a for-loop. But seems like a lot of work for just avoiding a for-loop. Users would need to understand the design.

Pros:

On the other hand, params::find does the same thing, assuming linear time is justifiable for URLs. Since params::find_all would also be linear time, it's not something completely without a precedent.

However, params::find has a much simpler interface, since we just return one iterator that already exists, so the precedent is not completely there.

from url.

vinniefalco avatar vinniefalco commented on August 16, 2024

we can just wait until a user requests it.

from url.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.