This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
do_in
and do_out
could do with better specificationSection: 28.3.4.2.5.3 [locale.codecvt.virtuals] Status: New Submitter: S. B. Tam Opened: 2025-06-18 Last modified: 2025-07-05
Priority: Not Prioritized
View other active issues in [locale.codecvt.virtuals].
View all other issues in [locale.codecvt.virtuals].
View all issues with New status.
Discussion:
Background: https://github.com/cplusplus/draft/pull/7347
The specification ofcodecvt::do_in
and codecvt::do_out
is unclear, and possibly incorrect:
the meaning of noconv
is specified twice (once in paragraph 3, once in Table 91 [tab:locale.codecvt.inout]);
the effect on from_next
is not specified;
the specification talks about "the input sequence [from, from_next)", but from_next
is supposed to be an out parameter.
I think it should say "[from, from_end)" instead.
Proposed resolution:
This wording is relative to N5008.
[Drafting note: This is modified from Jonathan Wakely's suggestion in https://github.com/cplusplus/draft/pull/7347#issuecomment]
In 28.3.4.2.5.3 [locale.codecvt.virtuals] remove Table 91 [tab:locale.codecvt.inout] in its entirety:
Table 91 —do_in
/do_out
result values [tab:locale.codecvt.inout]ValueMeaningok
completed the conversionpartial
not all source characters convertederror
encountered a character in[from, from_end)
that cannot be convertednoconv
internT
andexternT
are the same type, and input sequence is identical to converted sequence
Modify 28.3.4.2.5.3 [locale.codecvt.virtuals] as indicated:
result do_out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next, externT* to, externT* to_end, externT*& to_next) const; result do_in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next, internT* to, internT* to_end, internT*& to_next) const;-1- Preconditions: […]
-2- Effects: Translates characters in the source range[from, from_end)
, placing the results in sequential positions starting at destination to. Converts no more than(from_end - from)
source elements, and stores no more than(to_end - to)
destination elements. -3-Stops if it encounters a character it cannot convert. It always leaves theIffrom_next
andto_next
pointers pointing one beyond the last element successfully converted. If it returnsnoconv
,internT
andexternT
are the same type, and the converted sequence is identical to the input sequence[from, from_next)
,to_next
is set equal toto
, the value ofstate
is unchanged, and there are no changes to the values in[to, to_end)
.internT
andexternT
are the same type and the converted sequence would be identical to the input sequence [from
,from_next
), then no elements are converted, the value ofstate
is unchanged, there are no changes to the values in [to
,to_end
), and the result isnoconv
. Otherwise, if a character in [from
,from_end
) cannot be converted, conversion stops at that character and the result iserror
. Otherwise, if all input characters are successfully converted and placed in the output range, the result isok
. Otherwise, the result ispartial
. In all cases,from_next
is set to point to the first element of the input that was not converted,to_next
is set to point to the first unchanged element in the output. [Note: When the result isnoconv
,from_next
points tofrom
andto_next
points toto
. — end note] -4- Acodecvt
facet that is used bybasic_filebuf
[…] -5- Returns:An enumeration value, as summarized in Table 91The result as described above.