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: 2015-03-28 16:32:48


#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:
-------------------------------+----------------------------
Changes (by johnmaddock):

 * status: new => closed
 * resolution: => wontfix

Comment:

 This is to be expected, and is a side effect of returning expression
 templates from arithmetic operators, as mentioned in the introduction
 (http://www.boost.org/doc/libs/1_57_0/libs/multiprecision/doc/html/boost_multiprecision/intro.html#boost_multiprecision.intro.expression_templates)
 template argument type deduction may fail when passing the result of an
 expression to a template function.

 The workarounds are either:

 * Use a type with expression templates turned off - in your case that
 would be {{{number<cpp_dec_float_50::backend_type, et_off>}}}
 * Explicitly specify the template argumnent type for the call - so
 {{{std::max<cpp_dec_float_50>(x, 2*x)}}}, or:
 * Cast expressions prior to the call: {{{std::max(x,
 static_cast<cpp_dec_float_50>(2*x))}}}.

 I realise that the last 2 may not be possible if you don't control the
 code where the issue occurs, and that the first may have a performance
 impact (much lessened in C++11 though with move-semantics), but the only
 other alternative I can think of is to overload std::max - but that's not
 permitted by a strict reading of the standard I believe.

 Closing for now.... if a lot of folks fall into this trap I may reconsider

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11149#comment:1>
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:18 UTC