On 6/15/07, Skip Tavakkolian <[EMAIL PROTECTED]> wrote:
> I'm pretty sure I'm not good at it yet but I always found this one > line. "word counter" impressive. > > std::distance(std::istream_iterator<std::string>(std::cin), > std::istream_iterator<std::string>()); it is impressive that you typed that on a blackberry!
I'm not going to tell you that it was easy :-) it's not short, if you count the class implementation. it doesn't
convey the idea - the solution is not understood unless you understand each piece.
I disagree, to the extent that it really is short, in that it's one line :-) I agree as your point is 100% valid that if you don't know distance, istream_iterator, what cin is, and how it deals with "std::string", that you wouldn't know how to write that line, and you possibly wouldn't understand how it works. But I suspect any person dealing with C++ has an idea how the STL and Standard C++ Library works. What might still not be obvious is that that you need certain restrictions on iterators for STL to work (don't stable_sort on list iterators, as you probably need something with random access, not bi-directional iterators). (ok that was a bit tongue-in-cheek) No wonder there's so much money in C++ books :-) i think what Ron is bringing up is having/learning the ability to
see through layers of filters to the exact need and providing a design that is just the right distance between "pie in the sky" and "failure of vision". Yep, I was trying to point out that sometimes less code is more headache
:-) Of course when the plane door closes you have to shut off your phone so I don't think I got that across very well :-). At any rate, I'm hoping that's NOT what was meant by "Bell Labs Lines" :-) Dave
