The main use of the function “contains” in Boost ICL: are there any combinations of interval types and functions implemented?

I started using Boost ICL and I came across very simple things. For example, a function containsshould return true or false depending on whether this element is in the range or not. However, this works for [right,left]_open_intervals, but not for [open,closed]_inteval(see Example below).

This seems too obvious to be oversight. Am I using the library for the purpose?

For example (using gcc 4.8 or clang 3.3 and Boost 1.54):

#include <boost/concept_check.hpp> //needed to make this MWE work, boost icl should include it internally

#include<boost/icl/right_open_interval.hpp>
#include<boost/icl/closed_interval.hpp>
#include<boost/icl/open_interval.hpp>
int main(){
    boost::icl::right_open_interval<double> roi(6.,7.);
    assert(boost::icl::contains(roi, 6.) == true);  //ok
    assert(boost::icl::contains(roi, 6.) == false); //ok

    boost::icl::closed_interval<double> oi(4.,5.); // or open_interval
    assert(boost::icl::contains( oi, 4.) == false); //error: "candidate template ignored"
    assert(boost::icl::contains( oi, 5.) == false); //error: "candidate template ignored"
}

Note. The above terms are called “static” intervals (because their related properties are part of the type). Dynamic intervals work as expected.

+4
1

, .

- assert(0.1 + 0.2 == 0.3)?

. .

, , . :

, [a,b][b,c]. b ?

+2

Source: https://habr.com/ru/post/1532703/


All Articles