Re: [Boost-bugs] [Boost C++ Libraries] #11149: boost::multiprecision compilation fail with std::max

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11149: boost::multiprecision compilation fail with std::max
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-02-17 20:03:21


#11149: boost::multiprecision compilation fail with std::max
-------------------------------+----------------------------
  Reporter: minorlogic@… | Owner: johnmaddock
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: multiprecision
   Version: Boost 1.57.0 | Severity: Showstopper
Resolution: wontfix | Keywords:
-------------------------------+----------------------------

Comment (by johnmaddock):

 As noted above, the overloads I gave before are buggy... which is what
 happens when you try to just type in a quick fix :(

 This is what I plan to test:

 {{{
 template <class Backend, class tag, class A1, class A2, class A3, class
 A4>
 inline number<Backend, et_on> min(const number<Backend, et_on>& a, const
 detail::expression<tag, A1, A2, A3, A4>& b)
 {
    number<Backend, et_on> t(b);
    if(a < t)
       return a;
    return BOOST_MP_MOVE(t);
 }
 template <class tag, class A1, class A2, class A3, class A4, class
 Backend>
 inline number<Backend, et_on> min(const detail::expression<tag, A1, A2,
 A3, A4>& a, const number<Backend, et_on>& b)
 {
    number<Backend, et_on> t(a);
    if(t < b)
       return BOOST_MP_MOVE(t);
    return b;
 }
 template <class tag, class A1, class A2, class A3, class A4, class tagb,
 class A1b, class A2b, class A3b, class A4b>
 inline typename detail::expression<tag, A1, A2, A3, A4>::result_type
 min(const detail::expression<tag, A1, A2, A3, A4>& arg, const
 detail::expression<tagb, A1b, A2b, A3b, A4b>& a)
 {
    number<Backend, et_on> t1(a), t2(b);
    if(t1 < t2)
       return BOOST_MP_MOVE(t1);
    return BOOST_MP_MOVE(t2);
 }

 template <class Backend, class tag, class A1, class A2, class A3, class
 A4>
 inline number<Backend, et_on> max(const number<Backend, et_on>& a, const
 detail::expression<tag, A1, A2, A3, A4>& b)
 {
    number<Backend, et_on> t(b);
    if(a > t)
       return a;
    return BOOST_MP_MOVE(t);
 }
 template <class tag, class A1, class A2, class A3, class A4, class
 Backend>
 inline number<Backend, et_on> max(const detail::expression<tag, A1, A2,
 A3, A4>& a, const number<Backend, et_on>& b)
 {
    number<Backend, et_on> t(a);
    if(t > b)
       return BOOST_MP_MOVE(t);
    return b;
 }
 template <class tag, class A1, class A2, class A3, class A4, class tagb,
 class A1b, class A2b, class A3b, class A4b>
 inline typename detail::expression<tag, A1, A2, A3, A4>::result_type
 max(const detail::expression<tag, A1, A2, A3, A4>& arg, const
 detail::expression<tagb, A1b, A2b, A3b, A4b>& a)
 {
    number<Backend, et_on> t1(a), t2(b);
    if(t1 > t2)
       return BOOST_MP_MOVE(t1);
    return BOOST_MP_MOVE(t2);
 }
 }}}

 In addition you will need:

 {{{
 namespace std{ using boost::multiprecision::min; using
 boost::multiprecision::max;
 }}}

 Which is not valid C++ strictly speaking, but should get current/older
 eigen releases working... again untested... I will get to that sometime,
 but you may be quicker than me ;)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11149#comment:16>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC