Re: std::noskipws: #include<ios> or #include<iomanip>?
On Nov 18, 6:29 pm, Bernd Gaertner <gaert...@inf.ethz.ch> wrote:
James Kanze wrote:
It's rather arbitrary from a user point of view, but
manipulators which require an argument are declared in
<iomanip>, and those that don't are declared in <ios>.
Thanks. This seems to mean that for example the following code
(you find many similar things on the web) actually uses the
wrong include:
#include <iostream>
#include <iomanip> // for noskipws - (no skip whitespace)
char s;
int main()
{
std::cin >> std::noskipws;
while (std::cin >> s)
{
std::cout << s;
}
return 0;
}
Well, the comment is wrong, and the include of <iomanip> isn't
necessary here. But it doesn't hurt, and I can imagine some
house rules just saying to include it anytime you use a
manipulator, rather than having the developers have to learn the
detailed rule; it doesn't hurt. (Of course, <ios> will be
included indirectly by <iostream>, so there's no risk of the
manipulator not being defined.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34