473,386 Members | 1,943 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,386 software developers and data experts.

Non dereferencable iterator C++

Hi All,
I seem to be getting an error with my code when running Intel C++ compiler via Visual Studio 2005. The error generated is "Expression:map/set iterator not dereferencable"
I've given my code below in the hope that someone can spot the problem.
Many Thanks.......

Expand|Select|Wrap|Line Numbers
  1.  
  2.     set<stl_index>::iterator  eit1, eit2=elmt_ids.begin();
  3.     bool                               non_consecutive(false);
  4.  
  5.     // 0. checking whether the elements are consecutively numbered
  6.     for ( eit2++, eit1=elmt_ids.begin(); eit1!=elmt_ids.end(); eit1++, eit2++ )
  7.       if ( (*eit1)+1 != (*eit2) ) {
  8.            non_consecutive=true;
  9.            break; 
Feb 9 '08 #1
1 2852
weaknessforcats
9,208 Expert Mod 8TB
I have no idea why you are getting that error. I took your code and added other code (all assumptions) and got it to compile an link on Visual Studio.NET 2005.

This is what I compiled:
Expand|Select|Wrap|Line Numbers
  1. struct stl_index
  2. {
  3.     stl_index operator+(int arg) {stl_index temp; return temp;}
  4.     bool operator!=(stl_index  arg) {return true;}
  5. };
  6. set<stl_index> elmt_ids;
  7. void fx()
  8. {
  9. set<stl_index>::iterator  eit1, eit2=elmt_ids.begin();
  10.     bool                               non_consecutive(false);
  11.  
  12.     // 0. checking whether the elements are consecutively numbered
  13.     for ( eit2++, eit1=elmt_ids.begin(); eit1!=elmt_ids.end(); eit1++, eit2++ )
  14.     {
  15.       if ( (*eit1)+1 != (*eit2) )
  16.       {
  17.            non_consecutive=true;
  18.            break;
  19.       }
  20.     }
  21. }
  22.       int main()
  23.       {
  24.  
  25.       }
  26.  
Feb 9 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

38
by: Grant Edwards | last post by:
In an interview at http://acmqueue.com/modules.php?name=Content&pa=showpage&pid=273 Alan Kay said something I really liked, and I think it applies equally well to Python as well as the languages...
26
by: Michael Klatt | last post by:
I am trying to write an iterator for a std::set that allows the iterator target to be modified. Here is some relvant code: template <class Set> // Set is an instance of std::set<> class...
0
by: nick | last post by:
Hi, I need to manage a "layered" collection of objects, where each layer grows independently, e.g, o--+--+--+--+--+ 1st layer | o 2nd layer (empty) | o--+--+--+ 3rd...
14
by: shawnk | last post by:
I searched the net to see if other developers have been looking for a writable iterator in C#. I found much discussion and thus this post. Currently (C# 2) you can not pass ref and out arguments...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
16
by: mailforpr | last post by:
How do I do that? The thing is, the only information I have about the iterator is the iterator itself. No container it is belonging to or anything. Like template<Iteratorvoid...
1
by: David Bilsby | last post by:
All Apologies for cross posing this but I am not sure if this is a VC 8 STL bug or simply an invalid use of the iterator. I have a PCI card access class which basically abstracts a third party...
4
by: mkborregaard | last post by:
Hi, I have the weirdest problem, and I can not see what is going wrong. I have made a 2d container class, and am implementing an iterator for that class. However, the ++ operator is behaving very...
2
by: Piojolopez | last post by:
Hello guys, I have a problem with this code, the program is the resolution of Sudoku grid, the grid in my program is a vector of STL,and i use a list of STL for the right solution for each cell, to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.