C++ 错误:对';的调用没有匹配函数;std::\u Rb\u树\u迭代器

C++ 错误:对';的调用没有匹配函数;std::\u Rb\u树\u迭代器,c++,dictionary,C++,Dictionary,我在编译代码时遇到这个错误,我不明白为什么。我已经在其他方法中使用了相同的迭代,并且它是有效的 src/Stats/Stats.cpp:24:53: error: no matching function for call to'std::_Rb_tree_iterator<std::pair<const int, Onglet> >::_Rb_tree_iterator(std::map<int, Onglet>::const_iterator)' src

我在编译代码时遇到这个错误,我不明白为什么。我已经在其他方法中使用了相同的迭代,并且它是有效的

src/Stats/Stats.cpp:24:53: error: no matching function for call to'std::_Rb_tree_iterator<std::pair<const int, Onglet> >::_Rb_tree_iterator(std::map<int, Onglet>::const_iterator)'
src/Stats/Stats.cpp:24:53:错误:调用“std::\u Rb\u tree\u iterator::\u Rb\u tree\u iterator(std::map::const\u iterator)”时没有匹配的函数
类Stats有一个属性
std::map
stat

这是我的代码:

#include "Stats.hpp"
#include "./Application.hpp"
#include "./Utility/Utility.hpp"

//Constructeur:
Stats::Stats()
{}

//Destructeur:
Stats::~Stats()
{}

/*Dessin*/
void Stats::drawOn(sf::RenderTarget& target) const
{
    for(std::map<int,Onglet>::iterator i(stat.begin()); i != stat.end() ; ++i)
    {  
        int id = (i->first);
        if(id == identifiantActif)
        {
            (i->second).graphe->drawOn(target);
        }
    }
}


void Stats::setActive(int id)
{
    identifiantActif = id;
}

void Stats::reset()
{
    for(std::map<int,Onglet>::iterator i(stat.begin()); i != stat.end() ;  ++i)
    {
        (i->second).graphe->reset();    
    }   
}

void Stats::addGraph(int id,std::string const& title, 
                  std::vector<std::string> const& series, 
                   double min, double max, Vec2d const& size)
{

    for(std::map<int,Onglet>::iterator i(stat.begin()); i != stat.end() ; ++i)
    {
        setActive(id);
        stat[id].graphe.reset(new Graph(series,size,min,max));  
    }
}
#包括“Stats.hpp”
#包括“/Application.hpp”
#包括“/Utility/Utility.hpp”
//施工人员:
Stats::Stats()
{}
//析构函数:
统计::~Stats()
{}
/*德辛*/
void Stats::drawin(sf::RenderTarget&target)常量
{
for(std::map::迭代器i(stat.begin());i!=stat.end();++i)
{  
int id=(i->first);
if(id==identificantactif)
{
(一->秒)。图形->绘图(目标);
}
}
}
void Stats::setActive(int-id)
{
identificantactif=id;
}
void Stats::reset()
{
for(std::map::迭代器i(stat.begin());i!=stat.end();++i)
{
(i->second).graph->reset();
}   
}
void Stats::addGraph(int-id,std::string-const和title,
标准::矢量常数和系列,
双最小值、双最大值、矢量2D常量和大小)
{
for(std::map::迭代器i(stat.begin());i!=stat.end();++i)
{
setActive(id);
stat[id].Graph.reset(新图形(系列、大小、最小值、最大值));
}
}

您应该在标记为const的成员函数中使用
std::map::const_迭代器

如果没有更多信息,则不完全清楚发生了什么,但看起来您需要在
drawOn
中使用
const_迭代器
,因为它是一个const函数。您应该在成员函数中使用
std::map::const_迭代器
标记const@DieterL这是一个答案,不是评论。是的,谢谢,这是错误:)我必须使用常量迭代器:)