Topic: Defect Report: codecvt length/do_length signature mismatch


Author: "Anthony Williams" <anthwil@nortelnetworks.com>
Date: 17 Sep 2001 23:16:48 GMT
Raw View
[ moderator's note: Submitted to C++ Committee. Reply was that
  this report is the same as item #75 in the Library Issues list. -sdc ]

In the template class definition given for codecvt in 22.2.1.5
[lib.locale.codecvt], length and do_length are specified as taking "const
stateT&" as their first parameter, whereas every other member function
operating on a state object takes "stateT&".

However, in 22.2.1.5.1 [lib.locale.codecvt.members], length is specified as
taking a "stateT&" as its first parameter, and in  22.2.1.5.2
[lib.locale.codecvt.virtuals], do_length is also specified as taking a
"stateT&" as its first parameter, which is inconsistent.

The semantics are obviously different as the state object may be modified if
it is a non-const reference.

Specifying that the state object is passed as a "const stateT&" has benefits
for user code - users do not have to create a temporary copy of a state
object when determining the length for a future call of "in()", however it
also has a cost for library implementors where the process of determining
the length requires keeping track of the current state, using a "stateT"
object - the library implementor must first copy the given state to a local
object.

Proposed resolution:

Update 22.2.1.5.1 and 22.2.1.5.2 to reflect the template class definition in
22.2.1.5, with length and do_length taking a first parameter of type "const
stateT&"

Anthony
--
Anthony Williams
Software Engineer, Nortel Networks Optoelectronics
The opinions expressed in this message are not necessarily those of my
employer



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]