swapWithArray() needs some over-engineering

Currently swapWithArray only works with other arrays that have the same template arguments. Specifically, the type of critical section to use. I think it should look like this:

template <class OtherArrayType>
void swapWithArray (OtherArrayType& otherArray) noexcept
    const ScopedLockType lock1 (getLock());
    const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());

    data.swapWith (otherArray.data);
    std::swap (numUsed, otherArray.numUsed);

If you make this change please do it in all the containers that have the function!

Also its possible that the same idea applies to any other functions which take some other container as a parameter, as I believe all JUCE containers have a critical section template argument.

Things get a little tricky with SortedSet::swapWith but I’m sure your genius mind can sort that out Jules!

If you would rename Array::swapWithArray to Array::swapWith and make this consistent across all containers that would be great too, but I’m not expecting miracles.

Yes, that’s been niggling at me too, and I’ve been wanting to rename “swapWithArray” as “swapWith”. A good plan might be to keep the existing swapWithArray but deprecate it, and add a new templated swapWith method to replace it…

In your latest commit, SortedSet::swapWith doesn’t take a template argument