<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html><head>


   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Robert Klarer"><title>J16/06-0184 = WG21/N2114 -- long long Goes to the Library</title></head><body>
<pre><br>
                                        Doc No:   SC22/WG21/N2114
                                                  J16/06-0184
                                        Date:     2006-10-17
                                        Project:  JTC1.22.32
                                        Reply to: Robert Klarer
                                                  IBM Canada, Ltd.
                                                  klarer@ca.ibm.com
</pre>

<h1>long long Goes to the Library, Revision 1</h1>

<p>
This paper proposes a small number of straightforward and probably
uncontroversial changes to the Working Draft to complete integration of
the <code>long long</code> and <code>unsigned long long</code> types with the C++ Standard Library.  
</p>
<p>
This paper does not propose changes to the specification of the <code>&lt;random&gt;</code> library because we already have a document that does so: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2079.pdf">N2079, "Random Number Generation in C++0X: A Comprehensive Proposal, version 3"</a>
</p>
<p>
Among the changes proposed below is the addition of new virtual member functions (overloads of <code>do_get</code> and <code>do_put</code>) to the <code>num_get</code> and <code>num_put</code>
facets. Normally, the introduction of virtual functions to an existing
class interface will pose backwards binary compatibility problems for
implementers and, ultimately, programmers. I believe, however, that
these virtual functions are already implemented widely as conforming
extensions, so I predict that no backwards incompatibility will result
from the changes.
</p>

<p>This revision corrects embarrassing copy-and-paste typos in the original document, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2095.html">N2095</a>.


<h2>Proposed Working Draft changes</h2>
<h3>18.2.1 Numeric limits</h3>
<p>
add the following to "Header <limits> synopsis":
</limits></p>

<pre>        template&lt;&gt; class numeric_limits&lt;long long&gt;;
        template&lt;&gt; class numeric_limits&lt;unsigned long long&gt;;
</pre>

<h3>20.5 Function objects</h3>
<p>
add the following to "Header &lt;functional&gt; synopsis":
</p>

<pre>        template &lt;&gt; struct hash&lt;long long&gt;;
        template &lt;&gt; struct hash&lt;unsigned long long&gt;;
</pre>

<h3>
21.4 Null-terminated sequence utilities:
</h3>
<p>
add the following to "Table 63: Header &lt;cstdlib&gt; synopsis":
</p>

<pre>strtoull
</pre>

<h3>
22.2.2.1 Class template num_get
</h3>
<p>
add the following public member functions to the class definition:
</p>

<pre>        iter_type get(iter_type <i>in</i>, iter_type <i>end</i>, ios_base&amp;,
                      ios_base::iostate&amp; <i>err</i>, long long&amp; <i>v</i>)          const;
        iter_type get(iter_type <i>in</i>, iter_type <i>end</i>, ios_base&amp;,
                      ios_base::iostate&amp; <i>err</i>, unsigned long long&amp; <i>v</i>) const;
</pre>

<p>
add the following protected member functions to the class definition:
</p>

<pre>        virtual iter_type do_get(iter_type in, iter_type end, ios_base&amp;,
                                 ios_base::iostate&amp; err, long long&amp; v)          const;
        virtual iter_type do_get(iter_type in, iter_type end, ios_base&amp;,
                                 ios_base::iostate&amp; err, unsigned long long&amp; v) const;
</pre>

<h3>
22.2.2.1.1 num_get members
</h3>
<p>
add the following:
</p>

<pre>        iter_type get(iter_type <i>in</i>, iter_type <i>end</i>, ios_base&amp; <i>str</i>,
                      ios_base::iostate&amp; <i>err</i>, long long&amp; <i>val</i>)          const;
        iter_type get(iter_type <i>in</i>, iter_type <i>end</i>, ios_base&amp; <i>str</i>,
                      ios_base::iostate&amp; <i>err</i>, unsigned long long&amp; <i>val</i>) const;
</pre>

<h3>
22.2.2.1.2 num_get virtual functions
</h3>
<p>
to the list of function declarations before paragraph 1, add the following:
</p>

<pre>        iter_type do_get(iter_type <i>in</i>, iter_type <i>end</i>, ios_base&amp; <i>str</i>,
                         ios_base::iostate&amp; <i>err</i>, long long&amp; <i>val</i>)          const;
        iter_type do_get(iter_type <i>in</i>, iter_type <i>end</i>, ios_base&amp; <i>str</i>,
                         ios_base::iostate&amp; <i>err</i>, unsigned long long&amp; <i>val</i>) const;
</pre>

<p>
To "Table 70: Length Modifier," add the following rows:
</p>

<table border="1">
<tbody><tr>
<td>
<code>long long</code>
</td>
<td>
<code>ll</code>
</td>
</tr>
<tr>
<td>
<code>unsigned long long</code>
</td>
<td>
<code>ll</code>
</td>
</tr>
</tbody></table>

<h3>
22.2.2.2 Class template num_put
</h3>
<p>
add the following public member functions to the class definition:
</p>

<pre>        iter_type put(iter_type <i>s</i>, ios_base&amp; <i>f</i>, char_type <i>fill</i>,
                      long long <i>v</i>)          const;
        iter_type put(iter_type <i>s</i>, ios_base&amp; <i>f</i>, char_type <i>fill</i>,
                      unsigned long long <i>v</i>) const;
</pre>

<p>
add the following protected member functions to the class definition:
</p>

<pre>        virtual iter_type do_put(iter_type, ios_base&amp;, char_type <i>fill</i>,
                                 long long <i>v</i>)          const;
        virtual iter_type do_put(iter_type, ios_base&amp;, char_type <i>fill</i>,
                                 unsigned long long <i>v</i>) const;
</pre>

<h3>
22.2.2.2.1 num_put members
</h3>
<p>
to the list of function declarations before paragraph 1, add the following:
</p>

<pre>        iter_type put(iter_type <i>out</i>, ios_base&amp; <i>str</i>, char_type <i>fill</i>,
                      long long <i>v</i>)          const;
        iter_type put(iter_type <i>out</i>, ios_base&amp; <i>str</i>, char_type <i>fill</i>,
                      unsigned long long <i>v</i>) const;
</pre>

<h3>
22.2.2.2.1 num_put virtual functions
</h3>
<p>
to the list of function declarations before paragraph 1, add the following:
</p><p>

</p><pre>        iter_type do_put(iter_type <i>out</i>, ios_base&amp; <i>str</i>, char_type <i>fill</i>,
                         long long <i>v</i>)          const;
        iter_type do_put(iter_type <i>out</i>, ios_base&amp; <i>str</i>, char_type <i>fill</i>,
                         unsigned long long <i>v</i>) const;
</pre>

<p>
To "Table 73: Length Modifier," add the following rows:
</p>

<table border="1">

<tbody><tr>
<td>
<code>long long</code>
</td>
<td>
<code>ll</code>
</td>
</tr>
<tr>
<td>
<code>unsigned long long</code>
</td>
<td>
<code>ll</code>
</td>
</tr>
</tbody></table>

<p>These rows should appear above the row that reads "<i>otherwise</i>/<i>none</i>."

</p><h3>
27.6.1.1 Class template basic_istream
</h3>

<p>
Add the following formatted input operators to the class synopsis:
</p>

<pre>        // 27.6.1.2 Formatted input:
        ...
        basic_istream&lt;charT, traits&gt;&amp; operator&gt;&gt;(long long&amp; <i>n</i>);
        basic_istream&lt;charT, traits&gt;&amp; operator&gt;&gt;(unsigned long long&amp; <i>n</i>);
</pre>

<h3>
27.6.1.2.2 Arithmetic Extractors
</h3>
<p>
Add the following formatted input operators above paragraph 1:
</p>

<pre>        operator&gt;&gt;(long long&amp; <i>val</i>);
        operator&gt;&gt;(unsigned long long&amp; <i>val</i>);
</pre>

<h3>
27.6.2.1 Class template basic_ostream
</h3>
<p>
Add the following formatted input operators to the class synopsis:
</p>

<pre>        // 27.6.2.5 Formatted output:
        ...
        basic_ostream&lt;charT, traits&gt;&amp; operator&lt;&lt;(long long <i>n</i>);
        basic_ostream&lt;charT, traits&gt;&amp; operator&lt;&lt;(unsigned long long <i>n</i>);
</pre>

<h3>
27.6.2.5 Arithmetic Inserters
</h3>
<p>
Add the following formatted output operators above paragraph 1:
</p>

<pre>        operator&lt;&lt;(long long <i>val</i>);
        operator&lt;&lt;(unsigned long long <i>val</i>);
</pre>
<p>
end of paper.
</p>

</body></html>
