473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

reverse iterators revisited

Hello,

is it reasonable, that most stl-implementations allow conversion from
iterator to const_iterator via conversion constructors like the following?

template<class _Other>
reverse_iterator(const reverse_iterator<_Other>& _Right);

This signature unfortunately allows the other direction, wich is
semantically surely not the desired thing. GCC for example uses this way
not only for reverse_iterators.
I wrote equality comparison operators for reseverse iterators nad
const_reverse_iterators (see thread "reverse iterator operator==") and here
the trouble starts. Greenly, as I sometimes act, I wrote twice operator==()
(and twice operator!=):

template <typename Iter> // typename Const<Iter>::type is the const version
bool // of iterator type Iter. Some little magic :-).
operator==(const std::reverse_iterator<typename Const<Iter>::type> &lhs,
const std::reverse_iterator<Iter> &lhs);

template <typename Iter>
bool
operator==(const std::reverse_iterator<Iter> &lhs,
const std::reverse_iterator<typename Const<Iter>::type> &lhs);

and of course this yields ambiguity !!!

Tell me, what do you think of these STL reverse_iterator implementation. IMO
thei are doing it the easy way, allowing any reverse_iterator to be
converted to any other reverse_iterator. Even more, some allow this for
normal iterators, too. Doesn't this provoke trouble,

regards,
alex
Jul 22 '05 #1
0 1167

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Raymond Hettinger | last post by:
Here is a discussion draft of a potential PEP. The ideas grew out of the discussion on pep-284. Comments are invited. Dart throwing is optional. Raymond Hettinger ...
59
by: Raymond Hettinger | last post by:
Please comment on the new PEP for reverse iteration methods. Basically, the idea looks like this: for i in xrange(10).iter_backwards(): # 9,8,7,6,5,4,3,2,1,0 <do something with i> The...
31
by: Raymond Hettinger | last post by:
Based on your extensive feedback, PEP 322 has been completely revised. The response was strongly positive, but almost everyone preferred having a function instead of multiple object methods. The...
8
by: Alexander Stippler | last post by:
Hello, the standard requires a type reverse_iterator. But in the form it is required and implemented for all compilers I know, there is IMO something missing, which is essential for its usage....
1
by: Marcin Kaliciński | last post by:
template<class RanAccIt> void some_algorithm(RanAccIt begin, RanAccIt end) { // this algorithm involves calling std::lexicographical_compare // on range [begin, end), and on reverse of this range...
8
by: Jim Langston | last post by:
I have a class I designed that stores text chat in a std::vector<sd::string>. This class has a few methods to retrieve these strings to be displayed on the screen. void ResetRead( bool Reverse,...
15
by: Fabio Cannizzo | last post by:
Is it possible to do something similar to the STL iterators, i.e. to execute a foreach loop in reverse order? Thanks, Fabio
41
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
15
by: Boltar | last post by:
Hi I'm going through an STL list container using a reverse iterator but it seems the erase() method only accepts ordinary iterators. Is there a similar method that will accept reverse iterators...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.