Petter Petter - 8 months ago 28
C++ Question

C++ Boost Interval and cos

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
but have not been able to compile an example. I am not after very high precision. What I want is basically that adding two intervals is equivalent of adding two


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;