Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[locale] Example calls time_put::put with ios_base::iostate& but there is no such overload #3238

Closed
KalleOlaviNiemitalo opened this issue Sep 23, 2019 · 3 comments · Fixed by #3242
Assignees

Comments

@KalleOlaviNiemitalo
Copy link

[locale] paragraph 3 is this example:

draft/source/locales.tex

Lines 180 to 203 in e287e82

\begin{example}
An iostream
\tcode{operator<<}
might be implemented as:\footnote{Note that in the call to
\tcode{put}
the stream is implicitly converted to an
\tcode{ostreambuf_iterator<charT, traits>}.}
\begin{codeblock}
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<< (basic_ostream<charT, traits>& s, Date d) {
typename basic_ostream<charT, traits>::sentry cerberos(s);
if (cerberos) {
ios_base::iostate err = ios_base::iostate::goodbit;
tm tmbuf; d.extract(tmbuf);
use_facet<time_put<charT, ostreambuf_iterator<charT, traits>>>(
s.getloc()).put(s, s, s.fill(), err, &tmbuf, 'x');
s.setstate(err); // might throw
}
return s;
}
\end{codeblock}
\end{example}

In the put(s, s, s.fill(), err, &tmbuf, 'x') call, the fourth argument seems intended to be reference to ios_base::iostate err. However, in both put member functions in [locale.time.put.members], the fourth parameter is const tm* t:

draft/source/locales.tex

Lines 3977 to 3980 in e287e82

iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
const charT* pattern, const charT* pat_end) const;
iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
char format, char modifier = 0) const;

I suppose the definition and uses of ios_base::iostate err should be deleted from the example, and the code should instead call ostreambuf_­iterator<charT, traits>::failed(), like in [ostream.inserters.arithmetic].

If I understand correctly, the example is non-normative text, making this an editorial issue.

@jensmaurer
Copy link
Member

Please have a look at the pull request. Does this fix look correct?

@KalleOlaviNiemitalo
Copy link
Author

As I commented in #3242 (review), the change looks OK.

@zygoloid
Copy link
Member

zygoloid commented Oct 6, 2019

There's no such thing as ios_base::iostate::goodbit either :) I guess no-one ever tried compiling this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants