2

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)?

alfC
  • 14,261
  • 4
  • 67
  • 118
  • I *suspect* you can do it with di.bounds().bits(), but I'm really not sure, and I can't find it in the documentation. See here: http://www.boost.org/doc/libs/1_66_0/libs/icl/doc/html/boost/icl/discrete_interval.html#idp65029776-bb http://www.boost.org/doc/libs/1_66_0/libs/icl/doc/html/boost/icl/interval_bounds.html – Lukas Barth Mar 08 '18 at 15:44

0 Answers0