Formal answer: it depends on the implementation.
Unofficial answer: unordered_set inside is an array of (some) bucket, and most likely the implementation is consistent with vector , so this array will not be deleted when clear() called. Therefore, calling clear() is likely to bring some benefit.
source share