|
Boost Users : |
Subject: Re: [Boost-users] deleting operators to forbid mixed arithmetic? [multiprecision]
From: Dani Brake (danielthebrake_at_[hidden])
Date: 2017-08-15 22:13:48
Paul and John,
Putting a macro bracket around this might make it generally useful, perhaps
> something like:
>
> #ifdef BOOST_MULTIPRECISION_NO_DOUBLE_OPS (BUILTIN_OPS would include
> float and long double?)
>
> â¦
>
> template <class Backend>
> struct is_compatible_arithmetic_type<double, number<Backend> > : public
> mpl::false_ {};
>
> say
> #endif
>
> If you find this useful, you could create a GIT Pull Request, or just
> email the file changed. You wonât be the only one J. Defining the macro
> BOOST_MULTIPRECISION_NO_DOUBLE_OPS could be a way to detect dodgy
> conversions that need to be changed to keep full precision.
I implemented this in my codebase, and had few ill effects. Some
unexpected conversions, but I did find this disabling very useful.
Wrapping it in a macro bracket and making it officially supported would be
fabulous.
I think it should go in number_base.hpp at line 110 or so. If we wanted to
make it robust and thorough, I think we need to consider turning off
implicit constructors from disabled types, too. I believe that what we
have so far only disables arithmetic.
Dani
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net