Consider something like the following:
typedef std::unordered_multiset<int> Set;
typedef std::set<Set> SetOfSets;
SetOfSets somethingRecursive(SomeType somethingToAnalyze) {
Set s;
SetOfSets ss = somethingRecursive(somethingToAnalyze);
ss.insert(s);
return ss;
}
This approach is fairly standard for tasks such as creating subsets, permutations, etc. However, I tried to chart out what exactly Return Value Optimization should be optimized here, given the rather complex internal data structure of the type ( std::unordered_multisetis a hash table and std::setis usually a binary search tree), and I can only hope that the compilers are smarter than me .
So, speaking performance and (in case that matters) C++14, can I return SetOfSetshere or can I just pass it by reference as an out parameter?
sigil