c++ - error:cannot appear in constant expression while using multimap -
i writng program backtrace of process having multiple threads. using multimapping backtrace of each thread can mapped corresponding threadid.
here code:
multimap<int,std::vector<strings >frames>> mt;
............ ............
mt.insert(pair<int,std::vector<string>(threadid,funcname));
when compiling getting error error:'threadid' cannot appear in constant expression error:'funcname' cannot appear in constant expression.
please me in assigning values multimap.
one obvious error missing 1 closing angular bracket. replace this:
mt.insert(pair<int,std::vector<string>(threadid,funcname));
with this:
mt.insert(pair<int,std::vector<string> >(threadid,funcname)); // ^ here
you can simplify using std::make_pair
function template:
mt.insert(std::make_pair(threadid, funcname));
Comments
Post a Comment