<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2474: &lt;cmath&gt; functions unfriendly to integral_constant arguments</title>
<meta property="og:title" content="Issue 2474: &lt;cmath&gt; functions unfriendly to integral_constant arguments">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2474.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#NAD">NAD</a> status.</em></p>
<h3 id="2474"><a href="lwg-closed.html#2474">2474</a>. <code>&lt;cmath&gt;</code> functions unfriendly to <code>integral_constant</code> arguments</h3>
<p><b>Section:</b> 29.7 <a href="https://wg21.link/c.math">[c.math]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> Matheus Izvekov <b>Opened:</b> 2015-02-13 <b>Last modified:</b> 2015-12-17</p>
<p><b>Priority: </b>4
</p>
<p><b>View all other</b> <a href="lwg-index.html#c.math">issues</a> in [c.math].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Using numeric wrappers with <code>&lt;cmath&gt;</code> functions is currently troublesome.
Code such as: "<code>std::exp2(std::integral_constant&lt;int, 5&gt;{})</code>" will fail to 
compile because of ambiguity.
<p/>
Arguments which are implicitly convertible to an arithmetic type should be accepted whenever
the latter would be accepted.
<p/>
David Krauss pointed out that some issue may present itself with numeric libraries which provide <code>&lt;cmath&gt;</code> 
equivalents in their own namespace which are not more specialized than the ones provided in <code>&lt;cmath&gt;</code>. 
If the changes proposed are implemented, then cases where the user brings those into scope through ADL might become ambiguous.
<p/>
It's hard to assess how much breakage this would cause in the wild, and how much work it would take to fix. 
Should this be determined to be a problem, it's possible to make the new behaviour optional, and disabled by 
default for all user-defined types.
</p>

<p><i>[2015-10, Kona Saturday afternoon]</i></p>

<p>STL: This should be NAD, NAD-future and NAD-go-away. Users can already solve this using Walter's call syntax.</p>
<p>VV: I don't personally have this problem, but the proposed resolution seems frightening to me.</p>
<p>VV: There's a related issue, 2294, and also 2192.</p>
<p>STL: 2086 is about user-defined types in &lt;cmath&gt;, fixed in C++14. The PR for 2474 wants to undo the fix.</p>
<p>Link to <a href="lwg-defects.html#2086" title="Overly generic type support for math functions (Status: C++14)">2086</a><sup><a href="https://cplusplus.github.io/LWG/issue2086" title="Latest snapshot">(i)</a></sup> and NAD.</p>


<p id="res-2474"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4296.</p>

<ol>
<li>
<p>Change 29.7 <a href="https://wg21.link/c.math">[c.math]</a> p11 b2 as indicated:</p>
<blockquote>
<p>
-11- Moreover, there shall be additional overloads sufficient to ensure:
</p>
<ol>
<li><p>[&hellip;]</p></li>
<li><p>Otherwise, if any arithmetic argument corresponding to a <code>double</code> parameter has type <code>double</code> or 
<del>an integer type</del><ins>a type which is not floating-point, but which is implicitly convertible to <code>double</code></ins>, 
then all arithmetic arguments corresponding to <code>double</code> parameters are effectively cast to <code>double</code>.</p></li>
<li><p>[&hellip;]</p></li>
</ol>
</blockquote>
</li>
</ol>





</body>
</html>
