The Artima Developer Community
Sponsored Link

Articles Forum
On the Tension Between Object-Oriented and Generic Programming in C++

32 replies on 3 pages. Most recent reply: Nov 27, 2007 7:35 AM by Eivind Eklund

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 32 replies on 3 pages [ « | 1 2 3 ]
zade lao

Posts: 2
Nickname: zadechina
Registered: Sep, 2005

Re: On the Tension Between Object-Oriented and Generic Programming in C++ Posted: Nov 19, 2007 4:30 AM
Reply to this message Reply
Advertisement
any_iterator use type-erase tech to erase the actal type such as vector::iterator or list::iterator; in that case, it is only a iterator to access the elements in the container.

but yet any_iterator expose the iterator more details such as the iterator_tag. For my option, I want to only access elements with the type user defined. If you want to tell the iterator tag type to the user, you can use the runtime tech such as through tag_type() function.

so for template class any_iterator, the CategoryOrTraversal template argument should not needed; and to the extreme, all the argument except the Value are not needed. code like below:
template< class Value> class any_iterator;

in this case, type-erase tech is used in its extreme.

Thomas Becker

Posts: 14
Nickname: tmbecker
Registered: Oct, 2007

Re: On the Tension Between Object-Oriented and Generic Programming in C++ Posted: Nov 25, 2007 4:06 PM
Reply to this message Reply
> so for template class any_iterator, the
> CategoryOrTraversal template argument should not needed;
> and to the extreme, all the argument except the Value are
> not needed.

The point of these template arguments is to ensure that the any_iterator is a Standard-conforming iterator. Among other things, this ensures that the any_iterator works properly with generic algorithms of the kind found in the STL. If you really need to work with iterators that do not have these capabilities, my recommendation would be to avoid the term "iterator." I believe it's best to reserve the term "iterator" for Standard-conforming iterators.

Eivind Eklund

Posts: 49
Nickname: eeklund2
Registered: Jan, 2006

Re: On the Tension Between Object-Oriented and Generic Programming in C++ Posted: Nov 27, 2007 7:35 AM
Reply to this message Reply
> Ok, reply to myself:
>
> >They have chosen not to use the term "type erasure" at
> > all,
>
> I'm beginning to understand why some people are not happy
> with the term "type erasure." It does sound a bit like
> "making things typeless." Perhaps the person who posted
> the root message to this thread was a victim of this
> misunderstanding when he likened type erasure to using
> void*. (See, no matter what someone says, there is always
> some value in it.) Hm, what would be a better term? How
> about NIRP, for "non-intrusive runtime polymorphism" :o)

"Type normalization" or "Type canonicalization". The latter is probably better, though it is a mouthful. Using a common abbreviation for canonicalization, it would be "Type c14n", though that's only slightly better.

Eivind.

Flat View: This topic has 32 replies on 3 pages [ « | 1  2  3 ]
Topic: Flex and JavaFX Previous Topic   Next Topic Topic: Java EE 6

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use