将值添加到嵌套映射时出错,并将元组作为其值

时间:2016-09-07 20:12:06

标签: c++ c++11 typedef stdmap stdtuple

我一直在地图中维护一些统计数据,下面是我的typedef来创建地图

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)

两者都没有通过编译器总是在编译错误中结束,lemme输出了一些编译错误我已经

     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)我创建的结构是否有效?作业是否合适?

1 个答案:

答案 0 :(得分:1)

# Build Tree tree = ete3.Tree( "((a,b),c);" ) # Leaf mapping D_leaf_color = {"a":"r", "b":"g","c":None} # Set up style for circular tree ts = ete3.TreeStyle() ts.mode = "c" # Draw Tree tree.render("tree_test.png", dpi=300, w=500, tree_style=ts) insert来电中的最后一个参数是make_tuplesampleStatus[functionName][status::READY]=1,而元组期待int。这种类型的差异将导致您的错误。