Petter - 10 months ago 34

C++ Question

I have trouble using the Interval library from Boost

`#include <boost/numeric/interval.hpp>`

void test()

{

typedef boost::numeric::interval<double> Interval;

Interval i1(1.0, 2.0);

auto i2 = cos(i1);

}

I get the following compilation errors:

`transc.hpp(73): error C2039: 'cos_down' : is not a member of 'boost::numeric::interval_lib::rounded_math<double>'`

transc.hpp(73): error C2039: 'cos_up' : is not a member of 'boost::numeric::interval_lib::rounded_math<double>'

transc.hpp(75): error C2039: 'cos_up' : is not a member of 'boost::numeric::interval_lib::rounded_math<double>'

I have tried several combinations of

`interval_lib::policies`

`double`

Answer

The interval class expects rounding and checking policies. Change your interval typedef to the following and it should compile. You'll need to read through the documentation to understand exactly what policies you need in your case.

```
typedef interval<double, policies<save_state<rounded_transc_std<double> >,
checking_base<double> > > Interval;
```

Source (Stackoverflow)