Why the iterator_traits is needed?

I

izhak

Why do we need the iterator_traits if it's just a simple redefinition of
some of the Iterator concept's members?
 
B

Bo Persson

izhak said:
Why do we need the iterator_traits if it's just a simple
redefinition of some of the Iterator concept's members?

It's not just that.

There is also a specialization for pointer, which doesn't have the
concept members.

Pointers are also iterators!


Bo Persson
 
I

izhak

There is also a specialization for pointer, which doesn't have the
concept members.

Pointers are also iterators!


Bo Persson

Yes, now I understand... And for any other type, we my just specialize
it, to make that type usable in stl. Clear, thanks.
 
8

88888 Dihedral

izhakæ–¼ 2011å¹´12月30日星期五UTC+8上åˆ12時55分31秒寫é“:
Why do we need the iterator_traits if it's just a simple redefinition of
some of the Iterator concept's members?

I think to understand an iterator is important.

There are implementations of iterators.

Iterators are different from recursions in implementations.

In the abstract level the two does not differ too much.
 
8

88888 Dihedral

88888 Dihedralæ–¼ 2011å¹´12月30日星期五UTC+8上åˆ8時42分32秒寫é“:
izhakæ–¼ 2011å¹´12月30日星期五UTC+8上åˆ12時55分31秒寫é“:

I think to understand an iterator is important.

There are implementations of iterators.

Iterators are different from recursions in implementations.

In the abstract level the two does not differ too much.

But iterator in STL is more powerful. For example, there could be many
instances of timers in different classes of objects.

Each timer is defined clearly for the actions to be triggered in objects
that can access the timer in the next timer update event.

Thinking in the iterator way and the message driven mechanism is
better than the MS call back mechanism.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top