0
Table table;
             table.UpdateSeats(false, false, false, false, false, false);
	     std::list<bool>::iterator Test = table.GetSeats();
			
	     std::cout << "The current status of seats: ";
		for (int i = 0; i < 6; ++i) {
		     std::cout << " " << *Test;
		     ++Test;
		     std::cout << std::endl;
			}

No compiler errors or warnings, just a Debug Assertion Failed!

Expression: list iterator not incrementable. Any ideas?

Edited by PhysicsExpert: n/a

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by PhysicsExpert
Featured Replies
  • It looks like you have a fixed number of elements in the table and they are simple bool type. I would suggest you use either a static array or a class vector instead of list. The error you are reporting is weird... normally, this should execute just fine. The error … Read More

  • Did you initialize the list "Seats". If it is empty, then that would explain your error. Make sure it is not empty. Read More

1

It looks like you have a fixed number of elements in the table and they are simple bool type. I would suggest you use either a static array or a class vector instead of list. The error you are reporting is weird... normally, this should execute just fine. The error is either in the definition of Table (and GetSeats()) or that you have some non-standard (and faulty) implementation of the C++ STL. Please provide details on the definition of Table and what platform this is running on. Maybe you could try using "vector" instead of "list", just for a quick-fix of the problem.

Edited by mike_2000_17: n/a

0
class Table {

std::list<bool> Seats;

public:

	void UpdateSeats(bool SB, bool BB, bool EA, bool MP1, bool MP2, bool LA);
	std::list<bool>::iterator GetSeats(void);

};

std::list<bool>::iterator Table::GetSeats(void)
{
	std::list<bool>::iterator Get;
	Get = Seats.begin();
	return Get;
};

Using VS 2010 on Windows.

I just started with learning STL, so the error is most probably a fundemental one.

1

Did you initialize the list "Seats". If it is empty, then that would explain your error. Make sure it is not empty.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.