Re: Never ever use a raw pointer when a smart pointer can do the same
job
On Aug 15, 3:37 am, Keith H Duggar <dug...@alum.mit.edu> wrote:
On Aug 14, 6:28 am, James Kanze <james.ka...@gmail.com> wrote:
On Aug 13, 11:54 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
Noah Roberts wrote:
What purpose does a raw pointer serve?
The same as (random access) iterators?
Ah, but those are smart pointers:-). Not the type Noah was
thinking of, I think, but they're certainly more like smart
pointers than they are iterators. (In normal usage, "random
access iterator" is an oxymoron.)
Can you please expound upon 'In normal usage, "random access
iterator" is an oxymoron.' It seems like an interesting point
and I'm afraid I'm not quite seeing it entirely. Is it simply
that "iteration" in "normal" usage perhaps implies monotonic
sequencing? Or is there something deeper?
Not really. And "normal usage" probably isn't the best choice
of words. But traditionally, in pre-STL days, an iterator was a
means of visiting each element in a collection or a sequence
once, and exactly once. Possibly in some pre-defined order,
possibly not. Once you support random access, and things like
operator[], what you really have is a view.
At least, that's the terminology that was current in the circles
I frequented. Before the STL. Of course, terminology changes,
and what I called a view, above, I might now call the decorator
pattern:-). And when it's clear that I'm talking about C++,
well... in C++, the word "iterator" means exactly what the
standard chooses it to mean. (I don't mean that pejoritively;
in many ways, the standard has to take this route, in order to
be as precise as possible.)
--
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