<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.13.1: http://docutils.sourceforge.net/" />
<title>Class template deduction guides for &quot;diamond operators&quot;</title>
<meta name="date" content="2017-02-01" />
<meta name="author" content="Miro Knejp (miro.knejp&#64;gmail.com)" />
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

.subscript {
  vertical-align: sub;
  font-size: smaller }

.superscript {
  vertical-align: super;
  font-size: smaller }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
  overflow: hidden;
}

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin: 0 0 0.5em 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left, .figure.align-left, object.align-left, table.align-left {
  clear: left ;
  float: left ;
  margin-right: 1em }

img.align-right, .figure.align-right, object.align-right, table.align-right {
  clear: right ;
  float: right ;
  margin-left: 1em }

img.align-center, .figure.align-center, object.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

table.align-center {
  margin-left: auto;
  margin-right: auto;
}

.align-left {
  text-align: left }

.align-center {
  clear: both ;
  text-align: center }

.align-right {
  text-align: right }

/* reset inner alignment in figures */
div.align-right {
  text-align: inherit }

/* div.align-center * { */
/*   text-align: left } */

.align-top    {
  vertical-align: top }

.align-middle {
  vertical-align: middle }

.align-bottom {
  vertical-align: bottom }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font: inherit }

pre.literal-block, pre.doctest-block, pre.math, pre.code {
  margin-left: 2em ;
  margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
  border: 0px;
  border-top: 2px solid;
  border-bottom: 2px solid;
  border-collapse: collapse;
}
table.docutils.booktabs * {
  border: 0px;
}
table.docutils.booktabs th {
  border-bottom: thin solid;
  text-align: left;
}

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

ul.auto-toc {
  list-style-type: none }

</style>
<style type="text/css">

.hll { background-color: #ffffcc }
.c { color: #008000 } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #0000ff } /* Keyword */
.ch { color: #008000 } /* Comment.Hashbang */
.cm { color: #008000 } /* Comment.Multiline */
.cp { color: #0000ff } /* Comment.Preproc */
.cpf { color: #008000 } /* Comment.PreprocFile */
.c1 { color: #008000 } /* Comment.Single */
.cs { color: #008000 } /* Comment.Special */
.ge { font-style: italic } /* Generic.Emph */
.gh { font-weight: bold } /* Generic.Heading */
.gp { font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { font-weight: bold } /* Generic.Subheading */
.kc { color: #0000ff } /* Keyword.Constant */
.kd { color: #0000ff } /* Keyword.Declaration */
.kn { color: #0000ff } /* Keyword.Namespace */
.kp { color: #0000ff } /* Keyword.Pseudo */
.kr { color: #0000ff } /* Keyword.Reserved */
.kt { color: #2b91af } /* Keyword.Type */
.s { color: #a31515 } /* Literal.String */
.nc { color: #2b91af } /* Name.Class */
.ow { color: #0000ff } /* Operator.Word */
.sb { color: #a31515 } /* Literal.String.Backtick */
.sc { color: #a31515 } /* Literal.String.Char */
.sd { color: #a31515 } /* Literal.String.Doc */
.s2 { color: #a31515 } /* Literal.String.Double */
.se { color: #a31515 } /* Literal.String.Escape */
.sh { color: #a31515 } /* Literal.String.Heredoc */
.si { color: #a31515 } /* Literal.String.Interpol */
.sx { color: #a31515 } /* Literal.String.Other */
.sr { color: #a31515 } /* Literal.String.Regex */
.s1 { color: #a31515 } /* Literal.String.Single */
.ss { color: #a31515 } /* Literal.String.Symbol */

</style>
<style type="text/css">

/* code-formatted insertions to the standard */
pre.insert { background: lightgreen }

.std-section { font-weight: bold }

.std-note { font-style: italic }

</style>
</head>
<body>
<div class="document" id="class-template-deduction-guides-for-diamond-operators">
<h1 class="title">Class template deduction guides for &quot;diamond operators&quot;</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr class="document field"><th class="docinfo-name">Document:</th><td class="field-body">P0560R0</td>
</tr>
<tr><th class="docinfo-name">Date:</th>
<td>2017-02-01</td></tr>
<tr class="project field"><th class="docinfo-name">Project:</th><td class="field-body">Programming Language C++</td>
</tr>
<tr class="audience field"><th class="docinfo-name">Audience:</th><td class="field-body">Library Evolution Working Group</td>
</tr>
<tr><th class="docinfo-name">Author:</th>
<td>Miro Knejp (<a class="reference external" href="mailto:miro.knejp&#64;gmail.com">miro.knejp&#64;gmail.com</a>)</td></tr>
</tbody>
</table>
<div class="section" id="abstract">
<h1>Abstract</h1>
<p>This paper proposes a simplification of the syntax required to use library function types of the form <tt class="docutils literal"><span class="pre">less&lt;&gt;()</span></tt> (the so called &quot;diamond operators&quot;) to <tt class="docutils literal">less()</tt> by introducing class template deduction guides.</p>
<!-- .. contents:: -->
</div>
<div class="section" id="proposal">
<h1>Proposal</h1>
<p>The introduction of class template deduction allows for the simplification of the rather awkward syntax for the so called &quot;diamond operators&quot;, such as <tt class="docutils literal"><span class="pre">less&lt;&gt;()</span></tt> or <tt class="docutils literal"><span class="pre">plus&lt;&gt;()</span></tt>. They all have in common a single template parameter which defaults to <tt class="docutils literal">void</tt>. The simplification is achieved by creating deduction guides for the default constructors of these function types which deduce the template argument to <tt class="docutils literal">void</tt>:</p>
<pre class="literal-block">
func() -&gt; func&lt;void&gt;;
</pre>
</div>
<div class="section" id="proposed-wording">
<h1>Proposed Wording</h1>
<p>These changes are based on <a class="citation-reference" href="#n4618" id="id1">[N4618]</a>.</p>
<p>Change 20.14 [function.objects] paragraph 2 as follows:</p>
<blockquote>
<pre class="literal-block">
// 20.14.5, arithmetic operations
template &lt;class T = void&gt; struct plus;
template &lt;class T = void&gt; struct minus;
template &lt;class T = void&gt; struct multiplies;
template &lt;class T = void&gt; struct divides;
template &lt;class T = void&gt; struct modulus;
template &lt;class T = void&gt; struct negate;
template &lt;&gt; struct plus&lt;void&gt;;
template &lt;&gt; struct minus&lt;void&gt;;
template &lt;&gt; struct multiplies&lt;void&gt;;
template &lt;&gt; struct divides&lt;void&gt;;
template &lt;&gt; struct modulus&lt;void&gt;;
template &lt;&gt; struct negate&lt;void&gt;;
</pre>
<pre class="insert literal-block">
plus()       -&gt; plus&lt;void&gt;;
minus()      -&gt; minus&lt;void&gt;;
multiplies() -&gt; multiplies&lt;void&gt;;
divides()    -&gt; divides&lt;void&gt;;
modulus()    -&gt; modulus&lt;void&gt;;
negate()     -&gt; negate&lt;void&gt;;
</pre>
<pre class="literal-block">
// 20.14.6, comparisons
template &lt;class T = void&gt; struct equal_to;
template &lt;class T = void&gt; struct not_equal_to;
template &lt;class T = void&gt; struct greater;
template &lt;class T = void&gt; struct less;
template &lt;class T = void&gt; struct greater_equal;
template &lt;class T = void&gt; struct less_equal;
template &lt;&gt; struct equal_to&lt;void&gt;;
template &lt;&gt; struct not_equal_to&lt;void&gt;;
template &lt;&gt; struct greater&lt;void&gt;;
template &lt;&gt; struct less&lt;void&gt;;
template &lt;&gt; struct greater_equal&lt;void&gt;;
template &lt;&gt; struct less_equal&lt;void&gt;;
</pre>
<pre class="insert literal-block">
equal_to()      -&gt; equal_to&lt;void&gt;;
not_equal_to()  -&gt; not_equal_to&lt;void&gt;;
greater()       -&gt; greater&lt;void&gt;;
less()          -&gt; less&lt;void&gt;;
greater_equal() -&gt; greater_equal&lt;void&gt;;
less_equal()    -&gt; less_equal&lt;void&gt;;
</pre>
<pre class="literal-block">
// 20.14.7, logical operations
template &lt;class T = void&gt; struct logical_and;
template &lt;class T = void&gt; struct logical_or;
template &lt;class T = void&gt; struct logical_not;
template &lt;&gt; struct logical_and&lt;void&gt;;
template &lt;&gt; struct logical_or&lt;void&gt;;
template &lt;&gt; struct logical_not&lt;void&gt;;
</pre>
<pre class="insert literal-block">
logical_and() -&gt; logical_and&lt;void&gt;;
logical_or()  -&gt; logical_or&lt;void&gt;;
logical_not() -&gt; logical_not&lt;void&gt;;
</pre>
<pre class="literal-block">
// 20.14.8, bitwise operations
template &lt;class T = void&gt; struct bit_and;
template &lt;class T = void&gt; struct bit_or;
template &lt;class T = void&gt; struct bit_xor;
template &lt;class T = void&gt; struct bit_not;
template &lt;&gt; struct bit_and&lt;void&gt;;
template &lt;&gt; struct bit_or&lt;void&gt;;
template &lt;&gt; struct bit_xor&lt;void&gt;;
template &lt;&gt; struct bit_not&lt;void&gt;;
</pre>
<pre class="insert literal-block">
bit_and() -&gt; bit_and&lt;void&gt;;
bit_or()  -&gt; bit_or&lt;void&gt;;
bit_xor() -&gt; bit_xor&lt;void&gt;;
bit_not() -&gt; bit_not&lt;void&gt;;
</pre>
</blockquote>
</div>
<div class="section" id="references">
<h1>References</h1>
<table class="docutils citation" frame="void" id="n4618" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[N4618]</a></td><td><a class="reference external" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4618.pdf">Working Draft, Standard for Programming Language C++</a></td></tr>
</tbody>
</table>
</div>
<div class="section" id="acknowledgements">
<h1>Acknowledgements</h1>
<p>Adi Shavit and Simon Brand for initiating the thought process leading up to this paper.</p>
</div>
</div>
</body>
</html>
