Doc No: SC22/WG21/N2095 J16/06-0165 Date: 2006-09-07 Project: JTC1.22.32 Reply to: Robert Klarer IBM Canada, Ltd. klarer@ca.ibm.com
This paper proposes a small number of straightforward and probably uncontroversial changes to the Working Draft to complete integration of the long long
and unsigned long long
types with the C++ Standard Library.
This paper does not propose changes to the specification of the <random>
library for the simple reason that to do so would likely cause confusion. Since the LWG has agreed in principle to N1932, "Random Number Generation in C++0X: A Comprehensive Proposal," I think that it's prudent to wait until that proposal is formally approved and reconciled with the Working Draft before we attempt to patch it.
Among the changes proposed below is the addition of new virtual member functions (overloads of do_get
and do_put
) to the num_get
and num_put
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.
add the following to "Header
template<> class numeric_limits<long long>; template<> class numeric_limits<unsigned long long>;
add the following to "Header <functional> synopsis":
template <> struct hash<long long>; template <> struct hash<unsigned long long>;
add the following to "Table 63: Header <cstdlib> synopsis":
strtoull
add the following public member functions to the class definition:
iter_type get(iter_type in, iter_type end, ios_base&, ios_base::iostate& err, long long& v) const; iter_type get(iter_type in, iter_type end, ios_base&, ios_base::iostate& err, unsigned long long& v) const;
add the following protected member functions to the class definition:
virtual iter_type do_get(iter_type in, iter_type end, ios_base&, ios_base::iostate& err, long long& v) const; virtual iter_type do_get(iter_type in, iter_type end, ios_base&, ios_base::iostate& err, unsigned long long& v) const;
add the following:
iter_type get(iter_type in, iter_type end, ios_base& str, ios_base::iostate& err, long long& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, ios_base::iostate& err, unsigned long long& val) const;
to the list of function declarations before paragraph 1, add the following:
iter_type do_get(iter_type in, iter_type end, ios_base& str, ios_base::iostate& err, long long& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, ios_base::iostate& err, unsigned long long& val) const;
To "Table 70: Length Modifier," add the following rows:
long long
|
ll
|
unsigned long long
|
ll
|
add the following public member functions to the class definition:
iter_type put(iter_type s, ios_base& f, char_type fill, long long& v) const; iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long long& v) const;
add the following protected member functions to the class definition:
virtual iter_type do_put(iter_type, ios_base&, char_type fill, long long& v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long long& v) const;
to the list of function declarations before paragraph 1, add the following:
iter_type put(iter_type out, ios_base& str, char_type fill, long long& v) const; iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long long& v) const;
to the list of function declarations before paragraph 1, add the following:
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long& v) const; iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long long& v) const;
To "Table 73: Length Modifier," add the following rows:
long long
|
ll
|
unsigned long long
|
ll
|
These rows should appear above the row that reads "otherwise/none."
Add the following formatted input operators to the class synopsis:
// 27.6.1.2 Formatted input: ... basic_istream<charT, traits>& operator>>(long long& n); basic_istream<charT, traits>& operator>>(unsigned long long& n);
Add the following formatted input operators above paragraph 1:
operator>>(long long& val); operator>>(unsigned long long& val);
Add the following formatted input operators to the class synopsis:
// 27.6.2.5 Formatted output: ... basic_ostream<charT, traits>& operator<<(long long n); basic_ostream<charT, traits>& operator<<(unsigned long long n);
Add the following formatted output operators above paragraph 1:
operator<<(long long val); operator<<(unsigned long long val);
end of paper.