Date: Tue, 30 Jun 2020 15:46:22 -0600
> On Jun 30, 2020, at 11:46 AM, Ronan Keryell <rkeryell_at_[hidden]> wrote:
>
> […]
>> http://www.cplusplus.com/reference/iomanip/setw/
>>
>> Refers to both input and output streams but only describes output behavior concretely.
>>
>> http://www.cplusplus.com/reference/ios/ios_base/width/
>>
>> Its homologue width() on the other hand makes no mention of input at all.
>>
>> Can some clarity be shed on this?
>
> We cannot clarify all the websites talking about C++ on the Internet. :-)
>
> This mailing-list is about discussing the ISO C++ standard itself more
> than answering end-user questions. Perhaps places like
> https://stackoverflow.com/questions/tagged/c%2b%2b are more responsive
> for your question.
>
> Personally I find http://www.cplusplus.com quite obsolete compared to
> https://en.cppreference.com/w/ in the same domain. Perhaps it might
> answer your question if you dive into it.
>
Looking at:
https://en.cppreference.com/w/cpp/io/manip/setw
It claims that:
When used in an expression out << setw(n) or in >> setw(n), sets the width parameter of the stream out or in to exactly n.
But that doesn't seem to be the case for integer extractors. I think someone else called out that only std::string honors setw() on input, which seems arbitrary and violates the "Principle of Least Astonishment", or at least the expectation that object models & patterns get used uniformly and consistently.
Looking at:
https://en.cppreference.com/w/cpp/io/ios_base/width
Manages the minimum number of characters to generate on certain output operations and the maximum number of characters to generate on certain input operations.
By contrast mentions ONLY output, and omits any mention of input but then goes on to say
Notes
Some I/O functions call width(0) before returning, see std::setw (this results in this field having effect on the next I/O function only, and not on any subsequent I/O)
The exact effects this modifier has on the input and output vary between the individual I/O functions and are described at each operator<< and operator>> overload page individually.
And yes, on that note of "discussing the ISO C++ standard itself" I find guidance on uniformly implementing setw() on input streams to be lacking. Maybe it's worth fleshing out?
-Philip
>
> […]
>> http://www.cplusplus.com/reference/iomanip/setw/
>>
>> Refers to both input and output streams but only describes output behavior concretely.
>>
>> http://www.cplusplus.com/reference/ios/ios_base/width/
>>
>> Its homologue width() on the other hand makes no mention of input at all.
>>
>> Can some clarity be shed on this?
>
> We cannot clarify all the websites talking about C++ on the Internet. :-)
>
> This mailing-list is about discussing the ISO C++ standard itself more
> than answering end-user questions. Perhaps places like
> https://stackoverflow.com/questions/tagged/c%2b%2b are more responsive
> for your question.
>
> Personally I find http://www.cplusplus.com quite obsolete compared to
> https://en.cppreference.com/w/ in the same domain. Perhaps it might
> answer your question if you dive into it.
>
Looking at:
https://en.cppreference.com/w/cpp/io/manip/setw
It claims that:
When used in an expression out << setw(n) or in >> setw(n), sets the width parameter of the stream out or in to exactly n.
But that doesn't seem to be the case for integer extractors. I think someone else called out that only std::string honors setw() on input, which seems arbitrary and violates the "Principle of Least Astonishment", or at least the expectation that object models & patterns get used uniformly and consistently.
Looking at:
https://en.cppreference.com/w/cpp/io/ios_base/width
Manages the minimum number of characters to generate on certain output operations and the maximum number of characters to generate on certain input operations.
By contrast mentions ONLY output, and omits any mention of input but then goes on to say
Notes
Some I/O functions call width(0) before returning, see std::setw (this results in this field having effect on the next I/O function only, and not on any subsequent I/O)
The exact effects this modifier has on the input and output vary between the individual I/O functions and are described at each operator<< and operator>> overload page individually.
And yes, on that note of "discussing the ISO C++ standard itself" I find guidance on uniformly implementing setw() on input streams to be lacking. Maybe it's worth fleshing out?
-Philip
Received on 2020-06-30 16:49:35