Re: The way to read STL source code
On Feb 17, 2:15 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
On Feb 17, 11:57 am, Goran <goran.pu...@gmail.com> wrote:
On Feb 17, 10:12 am, Nick Keighley <nick_keighley_nos...@hotmail.com>
On Feb 17, 7:36 am, Goran <goran.pu...@gmail.com> wrote:
On Feb 17, 8:18 am, Stanley Rice <hecong...@gmail.com> wrote:
I am familiar with using STL, including the algorithm and the
containers, however, how they are implemented. Some of my friends
recommend me to read the source code of STL directly.
Reading is too dry.
nonsense!
I misunderstood here. Since I think reading the STL code is so
obviously mad I assumed you were saying "reading a book was too dry".
But I see not. If I want to know what the STL does I read Jossutis. or
use an online source.
Try debugging through it.
yuck!
Start with the simplest
of things, like for_each, vector::push_back, list::push_front. Just
make simplest of programs, e.g.
int main()
{
std::vector<char> v;
v.push_back('a');
}
and go through with the debugger.
In the beginning, it will be difficult, because you will need to le=
arn
to see through the cruft that's inside. Typically, you'll see a lot=
of
code whose sole purpose is to aid debugging. You'll need to learn t=
o
ignore that. You will also see bizarre variable naming. Live with i=
t.
Variable naming in STL is subject to different considerations than
your or mine code ;-).
or you could try poking your own eyes out
it just seems a lot of pain ...cruft...bizzare variable naming... for
very little gain.
I find that watching code unroll in the debugger is a great way of
learning what code does.
I'm less enthusiastic. Very unenthusiastic in fact. And it doesn't
help you learn what the STL /should/ be doing. Without reading some
sort of documentation I don't see how you'd even know certain features
existed.
From "how they are implemented" words of the OP, I took he wants to
see how STL is implemented. Doc normally says nothing about that.
Even more so when it's about usual STL
implementations code.
even less is my thought. The STL is particularly ugly lookign code.
Why do you care how it's implemented? Do you single shot through the C
libraries? You probably do I suppose...
Occasionally, yes. E.g. when I hit the problem I don't understand.
I don't get your excitement.
what excitement?
I interpreted e.g. "or you could try poking your own eyes out" as you
being agitated about my post. "Excitement" was the wrong word.
Goran.