C++ Boost Interval and cos



我在使用Boost中的Interval库时遇到了问题

#include <boost/numeric/interval.hpp>
void test()
{
    typedef boost::numeric::interval<double> Interval;
    Interval i1(1.0, 2.0);
    auto i2 = cos(i1);
}
我得到以下编译错误:
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>'

我已经尝试了interval_lib::policies的几个组合,但没有能够编译一个例子。我不追求很高的精度。我想要的是加两个间隔等于加两个double

interval类期望舍入和检查策略。将您的interval类型定义更改为以下内容,它应该可以编译。您需要通读文档,以准确了解在您的情况下需要哪些策略。

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

最新更新