Having problems with STL under VS 2005. I am restricted to VS 2005.
class SpeedTest
{
public:
void AddDataPair(const std::pair<std::string, double> & datum, const std::string & insertName = "");
private:
std::map <std::string, double> _Data;
}
void SpeedTest::AddDataPair(const pair<string, double> & datum, const string & insertName)
{
string key = insertName + '_' + datum.first;
_Data[key] += datum.second;
}
void SpeedTest::Insert(SpeedTest * toCopy, const string & insertName)
{
map<string, double>::iterator dataIter;
map<string, double>::iterator beginIter = toCopy->_Data.begin();
map<string, double>::iterator endIter = toCopy->_Data.end();
for_each
(
beginIter,
endIter,
bind2nd(mem_fun(&INGSpeedTest::AddDataPair)(), insertName)
);
}
I get error C2784:
'std::const_mem_fun1_t<_Result,_Ty,_Arg> std::mem_fun(Result (_thiscall _Ty::* )(_Arg) const)' :
could not deduce template argument for 'Result (_thiscall _Ty::* )(_Arg) const'
from 'void (__thiscall INGSpeedTest::* )(const std::pair<_Ty1,_Ty2> &,const std::string &)'
with
[
_Ty1=std::string,
_Ty2=double
]
If I replace the for_each with a for loop
for (dataIter = beginIter;
dataIter != endIter;
++dataIter)
{
AddDataPair(*dataIter, insertName);
}
It compiles nicely. But I would still like to know what is failing with the for_each.
Thank you very much for any time, knowledge and effort you can spare me,
Robert