Re: [9fans] a quick and simple minded study of configure.



On 6/15/07, Skip Tavakkolian <9nut@xxxxxxxxxxx> 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

Relevant Pages

  • Re: Lists and back() Question.
    ... > linked lists, I assumed endwould return NULL. ... Is there an open source STL I ... Iterators are abstractions of pointers. ... Iterators can become invalid when the container changes. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Is CArray best for this...
    ... Iterators have strange syntax, some STL construct needs to reference ".first" and ".second" is totally bizarre, etc. ... This is completely acceptable, and even desireable, for computer scientists, but not for app writers who are not interested in becoming experts in collections per se, only in that they allow them to write their apps. ...
    (microsoft.public.vc.mfc)
  • Re: OO Style with Ada Containers
    ... cursor/iterator and this is different from both STL and Java (STL ... anyway - in both cases iterators can be used to query as well as to ... algorithms work on whole containers. ...
    (comp.lang.ada)
  • Re: Why use STL?
    ... It is more than that in the STL. ... For example sort() requires random iterators to do its job. ... But it also means that if you wrote a brand new container, ...
    (microsoft.public.vc.stl)