alfC
alfC

Reputation: 16242

How to determine openness in Boost ICL interval?

In Boost.ICL, what is the canonical way to determine if an interval is closed or open?

Currently I am doing this:

#include<boost/icl/discrete_interval.hpp>
#include<iostream>
int main(){
   boost::icl::discrete_interval<int> di({2, 5}); // closed-open by default, but other combinations are possible
   if(contains(di, lower(di)) std::cout << "left closed\n"; else std::cout << "left open\n";
   if(contains(di, upper(di)) std::cout << "right closed\n"; else std::cout << "right open\n";
}

But it doesn't seem to be elegant.

Is there a function to determine that? (for dynamically bounded intervals)

Also, would it work for continuous_interval? and finally, is there a function (e.g. template value) to determine a compile type from static bounded interval (compile type defined boundaries)?

Upvotes: 2

Views: 324

Answers (0)

Related Questions