【发布时间】:2016-09-07 20:12:05
【问题描述】:
我一直在地图中维护一些统计数据,以下是我创建地图的类型定义
typedef Time TOTALTIME,MINM,MAXM,AVRG;
typedef std::map<std::string,std::map<status,int>> RequestStatus;//status is an enum
typedef std::tuple<int,TOTALTIME,MINM,MAXM,AVRG,RequestStatus> Attributes ;
typedef std::map<std::string,Attributes> requestStatistics ;
requestStatistics sampleStruct //我的最终地图
我一直在初始化,就像
sampleStruct.insert(make_pair(someskey,std::make_tuple(1,TOTALTIME(),MINM(),MAXM(),AVRG(),sampleStatus[functionName][status::READY]=1)));
我尝试过的其他方法
sampleStruct[somekey]=std::make_tuple(1,TOTALTIME(),MINM(),MAXM(),AVRG(),sampleStatus[functionName][status::READY]=1)
两者都没有通过编译器总是以编译错误结束,我得到了一些编译错误,我得到了
std::map<endstor::Data::statistics::status, int, std::less<endstor::Data::statistics::status>, std::allocator<std::pair<const endstor::Data::statistics::status, int> > >,
std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<endstor::Data::statistics::status, int, std::less<endstor::Data::statistics::status>, std::allocator<std::pair<const endstor::Data::statistics::status, int> > > > > > > > >]
insert(const_iterator __position, _Pair&& __x)
1)我创建的结构是否有效?分配是否正常?
【问题讨论】:
-
您包含的错误看起来与
RequestStatus的实例有关,而不是与requestStatistics的实例有关。请编辑您的问题以包含minimal reproducible example。
标签: c++ c++11 typedef stdmap stdtuple