Here is the code for the swap() function (based off of laserlight's example, and untested so far):
Code:
template<typename Key, typename T, typename SourceCompare, typename SourceAllocator>
multimap<Key, T, ResultCompare, ResultAllocator>
swap(map<Key, T, SourceCompare, SourceAllocator>& sourceMap) {
typedef map<Key, T, SourceCompare, SourceAllocator> sourceType;
typedef typename sourceType::const_iterator sourceIterator;
const sourceIterator end = sourceMap.end();
multimap<Key, T, SourceCompare, SourceAllocator> newMap;
for (sourceIterator i = sourceMap.begin(); i != end; i++) {
newMap.insert(make_pair(i->second, i->first));
}
return newMap;
}