This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::getline


On 15 May 2013 08:50, Jonathan Wakely wrote:
> On 15 May 2013 06:57, ntysdd wrote:
>> Hi,
>>
>> I found this in the file `include\bits\basic_string.h':
>> /**
>> * @brief Read a line from stream into a string.
>> * @param __is Input stream.
>> * @param __str Buffer to store into.
>> * @return Reference to the input stream.
>> *
>> * Stores characters from is into @a __str until '\n' is
>> * found, the end of the stream is encountered, or str.max_size()
>> * is reached. If __is.width() is non-zero, that is the limit on
>> * the number of characters stored into @a __str. Any previous
>> * contents of @a __str are erased. If end of line was
>> * encountered, it is extracted but not stored into @a __str.
>> */
>> template<typename _CharT, typename _Traits, typename _Alloc>
>> inline basic_istream<_CharT, _Traits>&
>> getline(basic_istream<_CharT, _Traits>& __is,
>> basic_string<_CharT, _Traits, _Alloc>& __str)
>> { return getline(__is, __str, __is.widen('\n')); }
>>
>>
>> But in reality I found __is.width() seemed to be completely ignored.
>> For example:
>>
>> #include <iostream>
>> #include <string>
>> using namespace std;
>> int main(void)
>> {
>>   string s;
>>   cin.width(3);
>>   getline(cin, s);
>>   cout << s << endl;
>>   return 0;
>> }
>>
>> Maybe the comment is wrong?
>
> Yes, it's wrong. I think the comment was copied from operator>> and
> not corrected.  I'll fix it, thanks for reporting it.

        * include/bits/basic_string.h (getline): Fix doxygen comments.

Committed to trunk so far.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]