The difference in purpose, although both do something similar.
rehash takes an existing map and rebuilds the new bucket size, rewrites the process and redistributes the elements into new buckets.
reserve guarantees you that if you do not enter more than the reserved number of elements, there will be no re-writing (i.e. your iterators will remain valid).
These are two different things, though related. rehash does not give you any guarantees, and reserve does not express the purpose of re-recording. Use rehash if you think your card is ineffective, and reserve if you are preparing for a lot of inserts.
As @Xeo points out, reserve is just a wrapper around rehash , although given the allowable load factor on the map.
source share