I'm trying to use a for_each loop in my code, but I'm getting the following error:
cannot convert parameter 1 from 'std::pair<_Ty1,_Ty2>' to 'std::pair<_Ty1,_Ty2> &'
here's the offending code:
typedef stdext::hash_map<
std::string, std::list<DefaultTestContext>
> CompleteTestList;
static void RunMappedTests(pair<string, list<DefaultTestContext>>& tests)
{
RunAllTestsInList(tests.second);
}
void RunTestsInParallel(CompleteTestList& testList)
{
for_each(testList.begin(), testList.end(), RunMappedTests);
}
Of course, the easy fix is to change RunMappedTests's parameter to be pass-by-value instead of pass-by-reference. Unfortunately, in this case, it comes with a huge performance penalty. It will have to copy a string, AND a list of ~64 byte data blocks. The amount of copying done is scary. I also NEED to modify the original elements in the map.
Anyone dealt with this before? Any easy fixes I don't know about?