<?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.5: http://docutils.sourceforge.net/" />
<title></title>
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 5196 2007-06-03 20:25:28Z wiemann $
: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 }

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

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

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

/* 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 {
  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 {
  clear: left }

img.align-right {
  clear: right }

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-family: serif ;
  font-size: 100% }

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

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 }

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>
</head>
<body>
<div class="document">


<div class="section" id="concept-mapping-unconstrained-templates">
<h1>Concept mapping unconstrained templates</h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Authors:</th><td class="field-body">Ville Voutilainen &lt;<a class="reference external" href="mailto:ville.voutilainen&#64;gmail.com">ville.voutilainen&#64;gmail.com</a>&gt; and Daniel Krügler &lt;<a class="reference external" href="mailto:daniel.kruegler&#64;googlemail.com">daniel.kruegler&#64;googlemail.com</a>&gt;</td>
</tr>
<tr class="field"><th class="field-name">Number:</th><td class="field-body">N2919=09-0109</td>
</tr>
<tr class="field"><th class="field-name">Date:</th><td class="field-body">2009-07-23</td>
</tr>
</tbody>
</table>
<div class="section" id="abstract">
<h2>Abstract</h2>
<p>This paper explains why it's important to be able to write concept
map templates for unconstrained templates. The cases this paper
is concerned with are cases where syntax adaptation is necessary.
This paper is meant as supplemental material for Core
Issue 911. Since concepts have been dropped from C++0x, the issue
is perhaps not of high priority, but we want to record this paper
so that the issue is not forgotten, should there be a redesign of concepts.</p>
</div>
</div>
<div class="section" id="the-problem">
<h1>The Problem</h1>
<p>Currently, it's not possible to write concept map templates for unconstrained
templates. The restriction as of N2914 is</p>
<pre class="literal-block">
14.11 [temp.constrained], paragraph 5

&quot;Within a constrained context, a program shall not require a template
specialization of an unconstrained
template for which the template arguments of the specialization depend
on a template parameter.&quot;
</pre>
<div class="section" id="the-problem-elaborated">
<h2>The problem elaborated</h2>
<p>There are many existing unconstrained templates that users will want to use
with concepts. Practical examples for the previous Range concept
are Qt containers (like QList) and Symbian containers (like RPointerArrays).
The former usually do not require syntax adaptation (and could thus be mapped
with empty concept map templates) for Range (or even Container), whereas the
latter do. For the short-term foreseeable future, these container
templates will remain unconstrained.</p>
<p>In addition to Range, there are other standard concepts that are
likely targets for early user adaptation, like the Container concepts.
These, too, cannot be currently mapped to from unconstrained templates.</p>
<p>When constrained template libraries become available, the same
adaptation problem arises for them - existing unconstrained templates
cannot be adapted to be used with the constrained templates by concept
map templates.</p>
<p>Given the amount of existing unconstrained template code, we state
that it's absolutely crucial to be able to map such templates to
concepts. Even after a redesign of concepts, we state that it's
paramount to provide a migration path to existing code, without
suggesting that existing code has to be constrained before it
can be used with concepts.</p>
</div>
<div class="section" id="code-example">
<h2>Code example</h2>
<p>The code example we wrote was written for concepts as proposed
to inclusion for C++0x. We decided to keep the example in this
paper, because it illustrates the problem.</p>
<p>There's a class in Qt that is a likely candidate for mapping to
InputIterator, the class in question is QDictIterator. It's
defined roughly as follows:</p>
<pre class="literal-block">
template&lt;class type&gt;
class QDictIterator : public QGDictIterator
{
 ...
  type* operator*();
  type* operator++();
  type* current() const;
};
</pre>
<p>In order to map it, we would like to write something like
the following:</p>
<pre class="literal-block">
template&lt;ObjectType T&gt;
concept_map InputIterator&lt;QDictIterator&lt;T&gt;&gt; {
 typedef T value_type;
 typedef T&amp; reference;
 typedef T* pointer;
 ...
 reference operator*(QDictIterator&lt;T&gt;&amp; it) { return *it.current(); }
 QDictIterator&lt;T&gt;&amp; operator++(QDictIterator&lt;T&gt;&amp; it) { ++it; return it; }
 pointer operator-&gt;(const QDictIterator&lt;T&gt;&amp; it) { return it.current(); }
 ...
}
</pre>
<p>This concept map is forbidden under the existing concepts. We could write
concept maps for specializations of QDictIterator, but that would
result in an explosion of boilerplate.</p>
<div class="section" id="why-is-this-a-core-issue">
<h3>Why is this a core issue?</h3>
<p>Some people have suggested that this is not a problem with
the core language at all, and people should just wait until
their libraries are constrained. We don't see this as a practical
approach, because we think the users should be able to use
concepts as soon as they have a concept-capable implementation
at their disposal, without having to wait for libraries to be constrained.</p>
<p>It is very likely that the necessary libraries will not be constrained
at the moment concept implementations become available, and for some
libraries, becoming constrained will take a long time, and further for
some libraries, may never happen. Thus we think the problem is caused
by the core language, and suggesting that libraries are constrained
before they can be used with constrained templates is an impractical solution.</p>
<p>We don't think it's necessarily possible to constrain libraries
from the top to bottom, so to speak. This is because the whole
reason for doing external adaptation via concept maps (and concept
map templates) is that the multiple template libraries need not
know anything about each other, and thus it would be difficult
to say which ones are at the &quot;bottom&quot; and which ones are on
&quot;top&quot;. Current popular template libraries can be mixed in
multiple ways and directions, without them being aware of
each other.</p>
</div>
</div>
</div>
<div class="section" id="solution-options">
<h1>Solution options</h1>
<p>We don't suggest solution options, because concepts are
not part of C++0x, and thus the problem is not current.
We do want concept designers to keep this issue in mind,
so that existing code is easy to adapt for use with
forthcoming concepts.</p>
</div>
</div>
</body>
</html>
