|
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | +<html><head> |
| 3 | +<meta http-equiv="Content-Language" content="en-us"> |
| 4 | +<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
| 5 | +<title>CWG-2398 Template template parameter matching and deduction</title> |
| 6 | + |
| 7 | +<style type="text/css"> |
| 8 | + |
| 9 | +body { color: #000000; background-color: #FFFFFF; } |
| 10 | +del { text-decoration: line-through; color: #8B0040; } |
| 11 | +ins { text-decoration: underline; color: #005100; } |
| 12 | + |
| 13 | +table { border-collapse: collapse; margin-left: auto; margin-right: auto; } |
| 14 | +th { border: 1px solid black; padding-left: 0.8em; padding-right: 0.8em; |
| 15 | + vertical-align: top; } |
| 16 | +td { border: 1px solid black; padding-left: 0.8em; padding-right: 0.8em; |
| 17 | + vertical-align: top; } |
| 18 | + |
| 19 | +span.comment { font-style: italic; } |
| 20 | +span.comment code { font-style: normal; } |
| 21 | +span.comment em { font-weight: bold; } |
| 22 | +span.comment var { font-style: normal; } |
| 23 | + |
| 24 | +p.example { margin-left: 1em; } |
| 25 | +pre.example { margin-left: 1em; } |
| 26 | +div.example { margin-left: 1em; } |
| 27 | + |
| 28 | +code.extract { background-color: #F5F6A2; } |
| 29 | +pre.extract { margin-left: 2em; background-color: #F5F6A2; |
| 30 | + border: 1px solid #E1E28E; } |
| 31 | + |
| 32 | +.attribute { margin-left: 2em; } |
| 33 | +.attribute dt { float: left; font-style: italic; |
| 34 | + padding-right: 1ex; } |
| 35 | +.attribute dd { margin-left: 0em; } |
| 36 | + |
| 37 | +blockquote.std { color: #000000; background-color: #F1F1F1; |
| 38 | + border: 1px solid #D1D1D1; |
| 39 | + padding-left: 0.5em; padding-right: 0.5em; } |
| 40 | +blockquote.std.ins { text-decoration: underline; |
| 41 | + color: #000000; background-color: #C8FFC8; |
| 42 | + border: 1px solid #B3EBB3; } |
| 43 | +blockquote.std.del { text-decoration: line-through; |
| 44 | + color: #000000; background-color: #FFC8EB; |
| 45 | + border: 1px solid #ECB3C7; } |
| 46 | +blockquote.std div { margin-top: 1em; margin-bottom: 1em; } |
| 47 | +blockquote.std ins { text-decoration: underline; |
| 48 | + color: #000000; background-color: #C8FFC8; } |
| 49 | +blockquote.std del { text-decoration: line-through; |
| 50 | + color: #000000; background-color: #FFC8EB; } |
| 51 | +blockquote.std ins * { background-color: inherit; } |
| 52 | +blockquote.std del * { background-color: inherit; } |
| 53 | +blockquote.std dt { margin-top: 1em; } |
| 54 | +blockquote.std ul { list-style-type: none; padding-left: 2em; |
| 55 | + margin-top: -0.2em; margin-bottom: -0.2em; } |
| 56 | +blockquote.std li { margin-top: 0.6em; margin-bottom: 0.6em; } |
| 57 | +blockquote.std ul > li::before { content: '\2014'; position: absolute; margin-left: -1.5em; } |
| 58 | +blockquote.std table { border: 1px solid black; border-collapse: collapse; |
| 59 | + margin-left: auto; margin-right: auto; margin-top: 0.8em; text-align: left; |
| 60 | + hyphens: none; } |
| 61 | +blockquote.std caption { margin-bottom: 1em; } |
| 62 | +blockquote.std th { border: inherit; padding-left: 1em; padding-right: 1em; vertical-align: top; } |
| 63 | +blockquote.std td { border: inherit; padding-left: 1em; padding-right: 1em; vertical-align: top; } |
| 64 | +blockquote.std th.left, td.left { text-align: left; } |
| 65 | +blockquote.std th.right, td.right { text-align: right; } |
| 66 | +blockquote.std th.center, td.center { text-align: center; } |
| 67 | +blockquote.std th.justify, td.justify { text-align: justify; } |
| 68 | +blockquote.std th.border, td.border { border-left: 1px solid black; } |
| 69 | +blockquote.std tr.rowsep, td.cline { border-top: 1px solid black; } |
| 70 | +blockquote.std tr.capsep { border-top: 3px solid black; border-top-style: double; } |
| 71 | +blockquote.std th { border-bottom: 1px solid black; } |
| 72 | + |
| 73 | +div.stdnote { display: inline; } |
| 74 | +div.stdexample { display: inline; } |
| 75 | + |
| 76 | +a.stdref::before { content: "["; } |
| 77 | +a.stdref::after { content: "]"; } |
| 78 | + |
| 79 | +table.frontmatter { border: 0; margin: 0; } |
| 80 | +table.frontmatter th { border: 0; } |
| 81 | +table.frontmatter td { border: 0; } |
| 82 | + |
| 83 | +span.highlight { background-color: #7FDFFF } |
| 84 | + |
| 85 | +</style> |
| 86 | + |
| 87 | +<script type="text/javascript" src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script> |
| 88 | +<script type="text/javascript"> |
| 89 | + document.addEventListener("DOMContentLoaded", function() { |
| 90 | + var notes = document.getElementsByClassName("stdnote"); |
| 91 | + for (var n = 0; n < notes.length; ++n) { |
| 92 | + var node = notes[n]; |
| 93 | + node.insertAdjacentHTML("beforebegin", |
| 94 | + "<span>[<span style=\"white-space:nowrap\"> <\/span><i>Note:<\/i> <\/span>"); |
| 95 | + node.insertAdjacentHTML("beforeEnd", |
| 96 | + "<span> —<span style=\"white-space:nowrap\"> <\/span><i>end note<\/i><span style=\"white-space:nowrap\"> <\/span>]<\/span>"); |
| 97 | + } |
| 98 | + |
| 99 | + var examples = document.getElementsByClassName("stdexample"); |
| 100 | + for (var n = 0; n < examples.length; ++n) { |
| 101 | + var node = examples[n]; |
| 102 | + node.insertAdjacentHTML("beforebegin", |
| 103 | + "<span>[<span style=\"white-space:nowrap\"> <\/span><i>Example:<\/i> <\/span>"); |
| 104 | + node.insertAdjacentHTML("beforeEnd", |
| 105 | + "<span> —<span style=\"white-space:nowrap\"> <\/span><i>end example<\/i><span style=\"white-space:nowrap\"> <\/span>]<\/span>"); |
| 106 | + } |
| 107 | + |
| 108 | + var references = document.getElementsByClassName("stdref"); |
| 109 | + for (var n = 0; n < references.length; ++n) { |
| 110 | + var node = references[n]; |
| 111 | + node.setAttribute("href", "http://eel.is/c++draft/" + node.innerText); |
| 112 | + } |
| 113 | + |
| 114 | + var wg21links = document.getElementsByClassName("wg21link"); |
| 115 | + for (var n = 0; n < wg21links.length; ++n) { |
| 116 | + var node = wg21links[n]; |
| 117 | + node.setAttribute("href", "https://wg21.link/" + node.innerText); |
| 118 | + } |
| 119 | + }); |
| 120 | +</script> |
| 121 | +</head> |
| 122 | + |
| 123 | +<body> |
| 124 | +<h1>CWG-2398 Template template parameter matching and deduction</h1> |
| 125 | +<table class="frontmatter" border="0" cellpadding="0" cellspacing="0" width="619"> |
| 126 | + <tr> |
| 127 | + <td align="left" valign="top">Document number:</td> |
| 128 | + <td>D????R0</td> |
| 129 | + </tr> |
| 130 | + <tr> |
| 131 | + <td align="left" valign="top">Date:</td> |
| 132 | + <td>2019-10-05</td> |
| 133 | + </tr> |
| 134 | + <tr> |
| 135 | + <td align="left" valign="top">Project:</td> |
| 136 | + <td>Programming Language C++, Core Working Group</td> |
| 137 | + </tr> |
| 138 | + <tr> |
| 139 | + <td align="left" valign="top">Reply-to:</td> |
| 140 | + <td>James Touton <<a href="mailto:bekenn@gmail.com">bekenn@gmail.com</a>></td> |
| 141 | + </tr> |
| 142 | +</table> |
| 143 | + |
| 144 | +<h2><a id="TableOfContents">Table of Contents</a></h2> |
| 145 | +<ol> |
| 146 | + <li><a href="#TableOfContents">Table of Contents</a></li> |
| 147 | + <li><a href="#RevisionHistory">Revision History</a></li> |
| 148 | + <li><a href="#DesignDecisions">Design Decisions</a></li> |
| 149 | + <li><a href="#Wording">Wording</a></li> |
| 150 | + <li><a href="#Acknowledgments">Acknowledgments</a></li> |
| 151 | + <li><a href="#References">References</a></li> |
| 152 | +</ol> |
| 153 | + |
| 154 | +<h2><a id="RevisionHistory">Revision History</a></h2> |
| 155 | +<h3>Revision 0 - 2019-10-05</h3> |
| 156 | +<ul> |
| 157 | +<li>Initial draft.</li> |
| 158 | +</ul> |
| 159 | + |
| 160 | +<h2><a id="DesignDecisions">Design Decisions</a></h2> |
| 161 | +<pre class="example"> |
| 162 | +<code class="prettyprint">template<class T, class U = T> class B { /* ... */ }; |
| 163 | +template<template<class> class P, class T> void f(P<T>); |
| 164 | + |
| 165 | +int main() |
| 166 | +{ |
| 167 | + f(B<int>()); // <span class="comment">OK?</span> |
| 168 | + f(B<int,float>()); // <span class="comment">ill-formed, T deduced to int and float</span> |
| 169 | +} |
| 170 | +</code> |
| 171 | +</pre> |
| 172 | + |
| 173 | +<p>The first line should be valid.</p> |
| 174 | + |
| 175 | +<pre class="example"> |
| 176 | +<code class="prettyprint">template<typename> struct match; |
| 177 | + |
| 178 | +template<template<typename> class t,typename T> |
| 179 | +struct match<t<T> > { typedef int type; }; // <span class="comment">#1</span> |
| 180 | + |
| 181 | +template<template<typename,typename> class t,typename T0,typename T1> |
| 182 | +struct match<t<T0,T1> > { typedef int type; }; // <span class="comment">#2</span> |
| 183 | + |
| 184 | +template<typename,typename = void> struct other { }; |
| 185 | +typedef match<other<void,void> >::type type; |
| 186 | +</code> |
| 187 | +</pre> |
| 188 | + |
| 189 | +<p>Valid or ambiguous? |
| 190 | +If valid, which partial specialization is selected?</p> |
| 191 | + |
| 192 | +<p>#2 should be selected.</p> |
| 193 | + |
| 194 | +<h2><a id="Wording">Wording</a></h2> |
| 195 | +<p>All modifications are presented relative to <a class="wg21link">N4830</a>. |
| 196 | +"<i>[...]</i>" indicates elided content that is to remain unchanged.</p> |
| 197 | + |
| 198 | +<h2><a id="Acknowledgments">Acknowledgments</a></h2> |
| 199 | + |
| 200 | +<h2><a id="References">References</a></h2> |
| 201 | + |
| 202 | +</body> |
| 203 | +</html> |
0 commit comments