Opened 6 years ago
Closed 6 years ago
#12720 closed Feature Requests (wontfix)
Implement is_floating_point and is_arithmetic for float128
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | multiprecision |
Version: | Boost 1.60.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The following program
#include <iostream> #include <random> #include <boost/multiprecision/float128.hpp> int main() { unsigned s = std::random_device()(); std::mt19937 g(s); std::uniform_real_distribution<boost::multiprecision::float128> dis; std::cout << dis(g) << "\n"; }
fails to compile with g++ 6.3.1 due to this static assertion failure
/usr/include/c++/6.3.1/bits/random.h:160:2: error: static assertion failed: template argument not a floating point type static_assert(std::is_floating_point<_DInputType>::value, ^~~~~~~~~~~~~
Note:
See TracTickets
for help on using tickets.
Sorry, no can do: type_traits work on the what kind of type an object is, not how they behave. float128 is a class type (and responds true to
is_class
), it genuinely should not respond true tois_arithmetic
etc.You code above should work fine if you use boost::mt19937 etc rather than the std versions.
It's probably worth while filing a gcc/libstdc++ bug report as well since the assert they are using could be replaced by one that uses numeric_limits<> to verify a type behaves as a floating point type - and numeric_limits is one trait we are allowed to specialize (and do so).