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-10-17
Priority: 3
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.
[2025-10-17; Reflector poll.]
Set priority to 3 after reflector poll.
"first element of the input that was not converted" doesn't make sense if there is no such element; similarly for the "first unchanged element".
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_outresult values [tab:locale.codecvt.inout]ValueMeaningokcompleted the conversionpartialnot all source characters convertederrorencountered a character in[from, from_end)that cannot be convertednoconvinternTandexternTare 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 the-4- Afrom_nextandto_nextpointers pointing one beyond the last element successfully converted. If it returnsnoconv,internTandexternTare the same type, and the converted sequence is identical to the input sequence[from, from_next),to_nextis set equal toto, the value ofstateis unchanged, and there are no changes to the values in[to, to_end).codecvtfacet that is used bybasic_filebuf[…] -5- Returns:An enumeration value, as summarized in Table 91.