重载boost :: multiprecision :: cpp_int参数

时间:2018-06-18 04:26:43

标签: c++ boost-multiprecision

当我尝试使用其他一些不相关的类类型重载boost::multiprecision::cpp_int类型的参数时,我得到了奇怪的错误。任何人都知道如何解决或解决这个问题?

test_program.cpp:

#include <boost/multiprecision/cpp_int.hpp>

class A {
public:
    virtual void abstract_fn() = 0;
};

extern void fn(boost::multiprecision::cpp_int);
extern void fn(const A &);

void test(const A *v) {
    fn(*v);
}

g ++ -c test_program.cpp:

In file included from /usr/include/c++/5/random:42:0,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /usr/include/boost/math/tools/config.hpp:17,
                 from /usr/include/boost/math/policies/error_handling.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:9,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/cpp_int.hpp:12,
                 from test_program.cpp:1:
/usr/include/c++/5/limits: In instantiation of ‘struct std::numeric_limits<A>’:
/usr/include/boost/multiprecision/detail/number_base.hpp:749:80:   required from ‘struct boost::multiprecision::number_category<A>’
/usr/include/boost/multiprecision/traits/is_restricted_conversion.hpp:21:38:   required from ‘struct boost::multiprecision::detail::is_lossy_conversion<A, boost::multiprecision::backends::cpp_int_backend<> >’
/usr/include/boost/multiprecision/traits/is_restricted_conversion.hpp:38:7:   required from ‘struct boost::multiprecision::detail::is_restricted_conversion<A, boost::multiprecision::backends::cpp_int_backend<> >’
/usr/include/boost/multiprecision/number.hpp:49:16:   required by substitution of ‘template<class V> boost::multiprecision::number<Backend, ExpressionTemplates>::number(const V&, typename boost::enable_if_c<((((boost::is_arithmetic<V>::value || boost::is_same<std::__cxx11::basic_string<char>, V>::value) || boost::is_convertible<V, const char*>::value) && (! boost::is_convertible<typename boost::multiprecision::detail::canonical<V, Backend>::type, Backend>::value)) && (! boost::multiprecision::detail::is_restricted_conversion<typename boost::multiprecision::detail::canonical<V, Backend>::type, Backend>::value))>::type*) [with V = A]’
test_program.cpp:12:10:   required from here
/usr/include/c++/5/limits:320:7: error: invalid abstract return type ‘A’
       min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
       ^
test_program.cpp:3:7: note:   because the following virtual functions are pure within ‘A’:
 class A {
       ^
test_program.cpp:5:18: note:        virtual void A::abstract_fn()
     virtual void abstract_fn() = 0;
                  ^

这是使用g ++ 5.4.0和boost v1.58(Ubuntu 16.04默认包)

0 个答案:

没有答案