<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1520: INVOKE on member data pointer with too many arguments</title>
<meta property="og:title" content="Issue 1520: INVOKE on member data pointer with too many arguments">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1520.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#C++11">C++11</a> status.</em></p>
<h3 id="1520"><a href="lwg-defects.html#1520">1520</a>. <code>INVOKE</code> on member data pointer with too many arguments</h3>
<p><b>Section:</b> 22.10.4 <a href="https://wg21.link/func.require">[func.require]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Howard Hinnant <b>Opened:</b> 2010-10-10 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#func.require">active issues</a> in [func.require].</p>
<p><b>View all other</b> <a href="lwg-index.html#func.require">issues</a> in [func.require].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++11">C++11</a> status.</p>
<p><b>Discussion:</b></p>

<p>
20.8.2 [func.require] p1 says:
</p>

<blockquote>
<p>
1 Define <code><i>INVOKE</i>(f, t1, t2, ..., tN)</code> as follows:
</p>

<ul>
<li>
<code>(t1.*f)(t2, ..., tN)</code> when <code>f</code> is a pointer to a member function
of a class <code>T</code> and <code>t1</code> is an object of type <code>T</code> or a
reference to an object of type <code>T</code> or a reference to an object of a type
derived from <code>T</code>;
</li>
<li>
<code>((*t1).*f)(t2, ..., tN)</code> when <code>f</code> is a pointer to a member
function of a class <code>T</code> and <code>t1</code> is not one of the types described
in the previous item;
</li>
<li>
<code>t1.*f</code> when <code>f</code> is a pointer to member data of a class <code>T</code>
and <code>t1</code> is an object of type <code>T</code> or a reference to an object of
type <code>T</code> or a reference to an object of a type derived from <code>T</code>;
</li>
<li>
<code>(*t1).*f</code> when <code>f</code> is a pointer to member data of a class
<code>T</code> and <code>t1</code> is not one of the types described in the previous
item;
</li>
<li>
<code>f(t1, t2, ..., tN)</code> in all other cases.
</li>
</ul>
</blockquote>

<p>
The question is:  What happens in the 3<sup><i>rd</i></sup> and
4<sup><i>th</i></sup> bullets when <code>N &gt; 1</code>?
</p>

<p>
Does the presence of <code>t2, ..., tN</code> get ignored, or does it make the
<code><i>INVOKE</i></code> ill formed?
</p>

<p>
Here is sample code which presents the problem in a concrete example:
</p>

<blockquote><pre>
#include &lt;functional&gt;
#include &lt;cassert&gt;

struct S {
   char data;
};

typedef char S::*PMD;

int main()
{
   S s;
   PMD pmd = &amp;S::data;
   std::reference_wrapper&lt;PMD&gt; r(pmd);
   r(s, 3.0) = 'a';  // well formed?
   assert(s.data == 'a');
}
</pre></blockquote>

<p>
Without the "<code>3.0</code>" the example is well formed.
</p>
<p>
[Note: Daniel provided wording to make it explicit that the above example is ill-formed. &mdash; end note ]
</p>

<p><i>[
Post-Rapperswil
]</i></p>


<blockquote><p>
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
</p></blockquote>

<p><i>[
Adopted at 2010-11 Batavia
]</i></p>




<p id="res-1520"><b>Proposed resolution:</b></p>

<p><i>The wording refers to N3126.</i></p>

<p>
Change 20.8.2 [func.require]/1 as indicated:
</p>
<blockquote>
<p>
1 Define <code><i>INVOKE</i>(f, t1, t2, ..., tN)</code> as follows:
</p>

<ul>
<li>
...
</li>
<li>
...
</li>
<li>
<code>t1.*f</code> when <ins><code>N == 1</code> and</ins> <code>f</code> is a pointer to
member data of a class <code>T</code> and <code>t1</code> is an object of type
<code>T</code> or a reference to an object of type <code>T</code> or a reference to an
object of a type derived from <code>T</code>;
</li>
<li>
<code>(*t1).*f</code> when <ins><code>N == 1</code> and</ins> <code>f</code> is a pointer to
member data of a class <code>T</code> and <code>t1</code> is not one of the types
described in the previous item;
</li>
<li>
...
</li>
</ul>
</blockquote>






</body>
</html>
