Domanda

How do I shift a discrete_interval using the Boost interval container library?

i.e. I want to subtract integer c from the lower() of the interval and from the upper() of the interval? Obviously I could create a new interval, but I'm looking for the canonical way to do this.

È stato utile?

Soluzione

The canonical way is to construct a new interval and assign it to your interval because boost::lcl::discrete_interval is immutable (apart from the assignment operator). So to shift an interval you have to create a new interval with the desired lower and upper bounds and assign it to the old interval.

boost::icl::discrete_interval<int> interval;
interval = boost::icl::discrete_interval<int>::closed(3, 4);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top