Hi, everyone. I need your help... I wanted to fill an std::map with some value_type arguments. When I run my code, the following error occured. Can anyone tell me how to fix it? Thanks!
error C2664: 'std::pair<_Ty1,_Ty2>::pair(const unsigned int &,const _Ty2 &)' : cannot convert parameter 2 from 'std::pair<_Ty1,_Ty2>' to 'const
1 2 3 4 5 6 7 8 9 10 11 12
typedef boost::numeric::ublas::vector<double> BVector;
typedef std::map<unsignedint,std::pair<unsignedint, std::vector<BVector>>> MyMap;
usingnamespace std;
using boost::numeric::ublas::zero_vector;
unsignedint iMaxLevel(1000);
vector<BVector> mean_var(iMaxLevel,zero_vector<double>(2));
vector<unsignedint> vn(iMaxLevel);
MyMap mapRes;
for(unsignedint i=0; i<iMaxLevel; ++i)
mapRes.emplace(i,make_pair(vn[i],mean_var[i])); // error urcurs in this line
make_pair(vn[i],mean_var[i]) gives you a std::pair<unsigned int, BVector>.
The value type of MyMap is std::pair<unsigned int, std::vector<BVector>>.
See the difference?
The type definition of MyMap is what I want. It is a vector of BVectors. For example, mean_var is a vector containing the statistics of mean_var.size() sets of samples.
I've been stuck with this problem for 6 hours...