Dear Experts,

I currently have:

template <typename KEY, typename VALUE, size_t SZ>
using small_flat_map =
  boost::container::flat_map<
    KEY,
    VALUE,
    std::less<KEY>,
    boost::container::small_vector<
      std::pair<KEY,VALUE>,
      SZ
    >
  >;

This works OK, but one thing that I do with it quite often is

  auto i = m.upper_bound(...);
  m.erase(m.begin(),i);

Erasing items at the start of the vector is of course the worst 
thing you can do for performance with a flat_map. So I was wondering 
if I can have a flat_map that stores its elements in the reverse 
order in the underlying vector.

Question: can anyone think of a way to do this that doesn't 
require changing all of the downstream code? For a few 
milliseconds I thought I could just change std::less for 
std::greater but that reverses the externally-visible 
behaviour. Is there some Boost utility that can wrap the 
implementation vector to work in reverse?


Thanks,

Phil.


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users

Reply via email to