Boost logo

Boost Users :

Subject: [Boost-users] [numeric/interval.hpp] compilation on clang++ vs g++
From: M B (vger2357_at_[hidden])
Date: 2018-06-27 13:22:56


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'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



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