Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support boost::multiprecision::cpp_int as BaseType #8

Open
emiliopaolini opened this issue Jun 29, 2021 · 1 comment
Open

Support boost::multiprecision::cpp_int as BaseType #8

emiliopaolini opened this issue Jun 29, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@emiliopaolini
Copy link

Hi everyone, as the title says, i was trying to use cpp_int defined in boost::multiprecision as base type. But when i declare a fixed point using cpp_int like this: using position = fpm::fixed<boost_int16_t, int128_t, 16>; i get some errors:
fpm/fixed.hpp:21:47: error: static assertion failed: BaseType must be an integral type
21 | static_assert(std::is_integral::value, "BaseType must be an integral type");

fpm/fixed.hpp:47:56: error: no match for 'operator*' (operand types are 'double' and 'const boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<15, 15, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void> >')
47 | : m_value(static_cast(std::round(val * FRACTION_MULT)))

And some other. Do you have any suggestions?

@MikeLankamp
Copy link
Owner

Currently, fpm::fixed requires its templated types to be integrals (via a std::is_integral check). Indeed it would be nice to support integral-like types like boost::multiprecision::cpp_int. I'm not sure yet how to verify at compile time that a type is integral-like, but I'll see what can be done. I'll turn this into a feature request.

@MikeLankamp MikeLankamp changed the title How to use boost::multiprecision cpp_int as base_type Support boost::multiprecision::cpp_int as BaseType Jun 29, 2021
@MikeLankamp MikeLankamp added the enhancement New feature or request label Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants