Opened 6 years ago

Last modified 5 years ago

#12765 new Feature Requests

Provide heterogeneous lookup methods using the container's hasher and/or comparator functions

Reported by: fdegros@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: intrusive
Version: Boost 1.63.0 Severity: Optimization
Keywords: Cc: fdegros@…

Description

Boost intrusive containers have heterogeneous lookup methods taking a key of an arbitrary type. All these methods also require to pass a hasher and/or a comparison function dealing with this key type. But what if the hasher/comparator embedded in the container itself can already deal with these key type? I'd like to avoid passing to these methods a function that the container already knows about.

Consider adding heterogeneous lookup methods using the hasher and/or comparator already stored in the container.

Like std::set or std::map, you might want to enable these methods only if the hasher and comparator declare a is_transparent nested type. See http://en.cppreference.com/w/cpp/container/map/find.

Something like:

template <typename T, class... Options> 
class set {
 public:
  ...

  template <typename K, typename = key_compare::is_transparent> 
  iterator find(const K& key) { return find(key, key_comp()); }
  ...
};

That would make these heterogeneous lookup methods more convenient to use.

Change History (3)

comment:1 by fdegros@…, 6 years ago

Ping? Any idea or progress on this topic?

comment:2 by Ion Gaztañaga, 6 years ago

It seems a good idea, written in the to-do list.

comment:3 by fdegros@…, 5 years ago

Ping? Any idea or progress on this topic?

Note: See TracTickets for help on using tickets.