<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Common Subset of C++03 and C++17: Binders</title>
<style type="text/css">
ins { background-color: #DFD; }
del { background-color: #FDD; }
</style>
</head>
<body>
<table>
  <tr>
    <td align="left">Project:</td>
    <td align="left">Programming Language C++</td>
  </tr>
  <tr>
    <td align="left">Document Number:</td>
    <td align="left">WG21/P0845R0</td>
  </tr>
  <tr>
    <td align="left">Date:</td>
    <td align="left">2017-10-13</td>
  </tr>
  <tr>
    <td align="left">Author:</td>
    <td align="left">Detlef Vollmann, <a href="mailto:dv@vollmann.ch">dv@vollmann.ch</a></td>
  </tr>
  <tr>
    <td align="left">Target audience:</td>
    <td align="left">LEWG, LWG</td>
  </tr>
</table>

<h1>P0845R0: Common Subset of C++03 and C++17: Binders</h1>

<h2>Introduction</h2>
<p>
There are many reasons to have source code that needs to compile across
a wide range of C and C++ compilers.
There are even more reasons to have source code that needs
to compile across a wide range of differnt C++ compilers and versions.
There are still many environments where only C++03 is supported.
However, with C++17 it turns out that while the common subset
of C and C++ is pretty stable, regardless of the version of C++,
the common subset between different C++ versions is shrinking significantly.
It would be bad to tell people to use the common subset of C and C++
if they want API stability.
</p>
<p>
All removals of features in a new version of C++ diminishes the
size of the common subset between the new version and the older ones.
The removal of the old C++98/03 function binders is an exceptionally
bad example of feature removal.
</p>
Some of the reasons include:
<ul>
  <li>The binders were widely used.</li>
  <li>The removal is optional, without even a feature macro.</li>
  <li>There's no syntactically and semantically equivalent replacement.</li>
</ul>

<h2>Easy solution</h2>

<p>
<strong>Put the binders back in.</strong>
</p>
<p>
This is the easiest solution and would solve all problems.
</p>

<h2>Complicated solution</h2>
If the binders are not put back in, for source code to work with old
and with new compilers several changes are required:
<ol>
  <li>Provide feature macros.</li>
  <li>Don't reserve the names if the binders are not provided.</li>
  <li>Specify the return types of bind functions
    or guarantee that <code>decltype</code> works.</li>
</ol>

<p>
For change 1, it would also be possible to disallow
still providing the binders (i.e. make the removal non-optional),
but I don't think anybody would like
this option (I don't).
</p>
<p>
Change 2 is not strictly required, but it doesn't make much sense
to reserve these names if the features aren't there and it makes
the life of the programmer somewhat easier if they don't have
to change the name globally.
</p>
<p>
Making <code>decltype</code> work in change 3
is the topic of a separate issue
(<a href="http://cplusplus.github.io/LWG/lwg-active.html#3023">LWG 3023</a>).
</p>
</body>
</html>
