使用boost interval_map [英] Using boost interval_map

查看:1138
本文介绍了使用boost interval_map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图跟随interval_map的 boost_party 比如我做了这个例子code:

Trying to follow the boost_party example of interval_map I made this example code:

#include "boost/icl/interval.hpp"
#include "boost/icl/interval_map.hpp"
#include <set>
using namespace std;

typedef std::set<string> ids;

int main(int argc, char* argv[])
{
    ids ids1;   
    ids1.insert("T1");
    ids ids2;
    ids2.insert("T2");
    boost::icl::interval_map<boost::icl::closed_interval<int>, ids> mymap;
    boost::icl::closed_interval<int> i1 = boost::icl::closed_interval<int>(2, 7);
    boost::icl::closed_interval<int> i2 = boost::icl::closed_interval<int>(3, 8);
    mymap += make_pair(i1, ids1);
    mymap += make_pair(i2, ids2);
    return 0;
}

但这种获取的这个编译错误:

But this get's this compilation error:

error: no match for ‘operator+=’ (operand types are ‘boost::icl::interval_map<boost::icl::closed_interval<int>, std::set<std::basic_string<char> > >’ and ‘std::pair<boost::icl::closed_interval<int>, std::set<std::basic_string<char> > >’)
  mymap += make_pair(i1, ids1);

任何想法有什么不对?

Any idea what's wrong?

推荐答案

应该最有可能是 mymap.insert(make_pair(...)); 而不是 MyMap中+ = make_pair(...); 。这对语法的std :: unordered_map

should most likely be mymap.insert(make_pair(...)); instead of mymap += make_pair(...);. That's the syntax for std::unordered_map.

这篇关于使用boost interval_map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆