के साथ const_iterator का उपयोग क्यों किया जा सकता है I erase
const iterator
पर इंप्रेशन का उपयोग नहीं कर सकता था। this code देखें।
नीचे कोड संकलित क्यों करता है (सी ++ 11, जीसीसी)?std :: map :: erase
long getMax(const bool get_new)
{
long max_val=0;
TO now=getNow();
map<TO, long>& m=get_new?m_new:m_old;
for(auto it=m.cbegin(); it !=m.cend())
{
if(now.compareTime((*it).first)<lookback)
{
max_val=max(max_val,
(*it).second);
++it;
}
else
{
it=m.erase(it);
}
}
return max_val;
}
map ही स्थिर नहीं है, लेकिन मैं समझता हूँ कि const iterator
इस असफल बनाना चाहिए है।