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

long long Goes to the Library, Revision 1

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 because we already have a document that does so: N2079, "Random Number Generation in C++0X: A Comprehensive Proposal, version 3"

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.

This revision corrects embarrassing copy-and-paste typos in the original document, N2095.

Proposed Working Draft changes

18.2.1 Numeric limits

add the following to "Header synopsis":

        template<> class numeric_limits<long long>;
        template<> class numeric_limits<unsigned long long>;

20.5 Function objects

add the following to "Header <functional> synopsis":

        template <> struct hash<long long>;
        template <> struct hash<unsigned long long>;

21.4 Null-terminated sequence utilities:

add the following to "Table 63: Header <cstdlib> synopsis":

strtoull

22.2.2.1 Class template num_get

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;

22.2.2.1.1 num_get members

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;

22.2.2.1.2 num_get virtual functions

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

22.2.2.2 Class template num_put

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;

22.2.2.2.1 num_put members

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;

22.2.2.2.1 num_put virtual functions

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."

27.6.1.1 Class template basic_istream

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);

27.6.1.2.2 Arithmetic Extractors

Add the following formatted input operators above paragraph 1:

        operator>>(long long& val);
        operator>>(unsigned long long& val);

27.6.2.1 Class template basic_ostream

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);

27.6.2.5 Arithmetic Inserters

Add the following formatted output operators above paragraph 1:

        operator<<(long long val);
        operator<<(unsigned long long val);

end of paper.