359. num_put<>::do_put (..., bool) undocumented

Section: 25.4.2.2.1 [facet.num.put.members] Status: CD1 Submitter: Martin Sebor Opened: 2002-03-12 Last modified: 2016-02-10

Priority: Not Prioritized

View all issues with CD1 status.

Discussion:

22.2.2.2.1, p1:

    iter_type put (iter_type out, ios_base& str, char_type fill,
                   bool val) const;
    ...

    1   Returns: do_put (out, str, fill, val).
    

AFAICS, the behavior of do_put (..., bool) is not documented anywhere, however, 22.2.2.2.2, p23:

iter_type put (iter_type out, ios_base& str, char_type fill,
               bool val) const;

Effects: If (str.flags() & ios_base::boolalpha) == 0 then do out = do_put(out, str, fill, (int)val) Otherwise do

             string_type s =
                 val ? use_facet<ctype<charT> >(loc).truename()
                     : use_facet<ctype<charT> >(loc).falsename();

and then insert the characters of s into out. out.

This means that the bool overload of do_put() will never be called, which contradicts the first paragraph. Perhaps the declaration should read do_put(), and not put()?

Note also that there is no Returns clause for this function, which should probably be corrected, just as should the second occurrence of "out." in the text.

I think the least invasive change to fix it would be something like the following:

Proposed resolution:

In 25.4.2.2.2 [facet.num.put.virtuals], just above paragraph 1, remove the bool overload.

In 25.4.2.2.2 [facet.num.put.virtuals], p23, make the following changes

Replace put() with do_put() in the declaration of the member function.

Change the Effects clause to a Returns clause (to avoid the requirement to call do_put(..., int) from do_put (..., bool)) like so:

23 Returns: If (str.flags() & ios_base::boolalpha) == 0 then do_put (out, str, fill, (long)val) Otherwise the function obtains a string s as if by

             string_type s =
                val ? use_facet<ctype<charT> >(loc).truename()
                    : use_facet<ctype<charT> >(loc).falsename();

and then inserts each character c of s into out via *out++ = c and returns out.

Rationale:

This fixes a couple of obvious typos, and also fixes what appears to be a requirement of gratuitous inefficiency.