The code below is supposed to insert two intervals with associated values 0 and 1 into the Boost interval map, but it inserts only one:
#include <iostream>
#include <boost/icl/interval_map.hpp>
using Interval = boost::icl::interval<int>;
using IMap = boost::icl::interval_map<int, int>;
int main()
{
IMap m;
m += std::make_pair(Interval::right_open(0, 7), 0); // <== ignored?
m += std::make_pair(Interval::right_open(8,15), 1);
std::cout << m << std::endl;
}
Output:
{([8,15)->1)}
If I change the value for the "ignored" line to 1, it will insert the pair correctly.
Why is that?
Any domain interval with "no value" has an implicit "0" in the co-domain. And vice versa. I guess the following sample would make sense immediately:
Results in an empty map.
See Map Traits.
Specifically under Definedness and Storage of Identity Elements