I am doing line-oriented file input in C++ using the global getline function defined in the <string> header. Various books demonstrate getline's idiomatic use:
The function prototype for getline is:Code:#include <fstream> #include <iostream> #include <string> . . std::ifstream infile("foo.txt"); . . std::string aline; while (std::getline(infile, aline)) { // process line . . }
istream& getline(istream& is, string& s, char delimiter = '\n');
So getline returns a reference to istream. My question is, how can it be used in a while expression, which expects a boolean? I'm guessing some implicit conversion takes place, but it's not apparent to me from the standard library API docs.
Thanks for your help.



LinkBack URL
About LinkBacks



CornedBee