In the sharecontainer template, there is code in get() to ensure that
the container is sorted by decreasing use count order. It looks like:

                        // move it forward - optimization
                        // makes the next find faster.
                        if (it != params.begin())
                                std::swap(*it, *(it - 1));

Shouldn't we have something like the following (untested) code

  const_iterator it2 = it;
  while (it2 != params.begin() 
         && (*it2).use_count() == (*it).use_count())
        --it2;
  if (it != it2)
        std::swap(*it, *it2);

Of course, I suspect that the use_count values have already been
updated somewhere, so my tests may not be alright. Anyway, the idea is
that we may have to swap depending on the use_count(), not always.

Am I misunderstanding how it works?

JMarc

Reply via email to