This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
562. stringbuf ctor inefficientSection: 31.8 [string.streams] Status: CD1 Submitter: Martin Sebor Opened: 2006-02-23 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [string.streams].
View all issues with CD1 status.
Discussion:
For better efficiency, the requirement on the stringbuf ctor that takes a string argument should be loosened up to let it set epptr()
beyond just one past the last initialized character just like overflow()
has been changed to be allowed to do (see issue 432). That way the first call to sputc()
on an object won't necessarily cause a call to overflow
. The corresponding change should be made to the string overload of the str()
member function.
Proposed resolution:
Change 27.7.1.1, p3 of the Working Draft, N1804, as follows:
explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& str, ios_base::openmode which = ios_base::in | ios_base::out);-3- Effects: Constructs an object of class
basic_stringbuf
, initializing the base class withbasic_streambuf()
(27.5.2.1), and initializingmode
withwhich
. Then callsstr(s)
. copies the content of str into thebasic_stringbuf
underlying character sequence. Ifwhich & ios_base::out
is true, initializes the output sequence such thatpbase()
points to the first underlying character,epptr()
points one past the last underlying character, andpptr()
is equal toepptr()
ifwhich & ios_base::ate
is true, otherwisepptr()
is equal topbase()
. Ifwhich & ios_base::in
is true, initializes the input sequence such thateback()
andgptr()
point to the first underlying character andegptr()
points one past the last underlying character.
Change the Effects clause of the str()
in 27.7.1.2, p2 to read:
-2- Effects: Copies the content s of
s
into thebasic_stringbuf
underlying character sequence and initializes the input and output sequences according tomode
. Ifmode & ios_base::out
is true, initializes the output sequence such thatpbase()
points to the first underlying character,epptr()
points one past the last underlying character, andpptr()
is equal toepptr()
ifmode & ios_base::in
is true, otherwisepptr()
is equal topbase()
. Ifmode & ios_base::in
is true, initializes the input sequence such thateback()
andgptr()
point to the first underlying character andegptr()
points one past the last underlying character.-3- Postconditions: If
mode & ios_base::out
is true,pbase()
points to the first underlying character and(epptr() >= pbase() + s.size())
holds; in addition, ifmode & ios_base::in
is true,(pptr() == pbase() + s.data())
holds, otherwise(pptr() == pbase())
is true. Ifmode & ios_base::in
is true,eback()
points to the first underlying character, and(gptr() == eback())
and(egptr() == eback() + s.size())
hold.
[ Kona (2007) Moved to Ready. ]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4