[numeric/interval.hpp] compilation on clang++ vs g++

This may be a somewhat newbie question.This is cross-posted on stack exchange before I found this list. (https://stackoverflow.com/questions/51062374/different-behavior-with-enable-...) I'm having trouble compiling the following piece of boost-based code: ***** #include <boost/numeric/interval.hpp> #include <complex> int main(){ std::complex<boost::numeric::interval<double> > my_interval(1,1); my_interval *= my_interval; return 0;} ***** When I compile using g++ (MacPorts gcc5 5.5.0_1), I get no compilation errors (g++ -std=c++14 main.cpp). When I compile using clang++ (Apple LLVM version 8.1.0 (clang-802.0.38)), I get compilation errors (clang++ -std=c++14 main.cpp). Summarizing the error, it appears that an enable_if in cmath (line 424: std::enable_if<std::is_arithmetic<_A1>::value, bool>::type) is preventing isnan from being defined for boost::numeric::interval<double> (at least in clang++). Am I doing something wrong or is there a work around? I realize that this might be more of a std::complex question than a boost question, but since it involves boost, I thought that I'd ask here. Thank you. The full and complete error is below. ***** Full and Complete Error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:599:9: error: no matching function for call to 'isnan' if (isnan(__x) && isnan(__y)) ^~~~~/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:312:27: note: in instantiation of function template specialization 'std::__1::operator*<boost::numeric::interval<double, boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>, boost::numeric::interval_lib::checking_strict<double> > > >' requested here *this = *this * complex(__c.real(), __c.imag()); ^main.cpp:6:15: note: in instantiation of function template specialization 'std::__1::complex<boost::numeric::interval<double, boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>, boost::numeric::interval_lib::checking_strict<double> > > >::operator*=<boost::numeric::interval<double, boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>, boost::numeric::interval_lib::checking_strict<double> > > >' requested here my_interval *= my_interval; ^/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:424:25: note: candidate template ignored: disabled by 'enable_if' [with _A1 = boost::numeric::interval<double, boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>, boost::numeric::interval_lib::checking_strict<double> > >]typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type

On Wed, Jun 27, 2018 at 6:22 AM, M B via Boost-users < boost-users@lists.boost.org> wrote:
This may be a somewhat newbie question. This is cross-posted on stack exchange before I found this list. (https://stackoverflow.com/questions/51062374/ different-behavior-with-enable-if-using-clang-and-g)
I've responded over on SO as well, but the problem is that boost::numeric::interval is instantiating std::complex with a user-defined type, and the standard gives no assurances that this will work. [complex.numbers]/2 says: The effect of instantiating the template complex for any type other than
float, double, or long double is unspecified.
-- Marshall
participants (2)
-
M B
-
Marshall Clow