Could you have a race-condition?
If the list were empty, then I’d expect a problem when trying to dereference begin(), but you check for empty. Do you have another thread adding or removing items from list in parallel?
Your code snippets works for me on VS 2008 (assuming I typedef Counted_message_reader
to int
).
Related Posts:
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- How to navigate through a vector using iterators? (C++)
- How do I erase an element from std::vector<> by index?
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- How do I reverse a C++ vector?
- A proper way to create a matrix in c++
- How to iterate through a list of objects in C++?
- Pointer to incomplete class type is not allowed
- Why use string::iterator rather than index?
- push_back vs emplace_back
- Parsing a comma-delimited std::string
- How to ensure that a std::map is ordered?
- How to iterate over a vector?
- error C2011: ” : ‘class’ type redefinition
- push_back vs emplace_back
- Remove spaces from std::string in C++
- Remove spaces from std::string in C++
- How to check that an element is in a std::set?
- What’s the most efficient way to erase duplicates and sort a vector?
- Best way to extract a subvector from a vector?
- How can I iterate through a string and also know the index (current position)?
- Appending a vector to a vector
- Determine if map contains a value for a key?
- C++ Erase vector element by value rather than by position?
- why can’t I dereference an iterator?
- How to get current time in milliseconds?
- Use the auto keyword in C++ STL
- std::string length() and size() member functions
- Iterator Loop vs index loop
- sorting in std::map where key is a std::string
- How to do std::string indexof in C++ that returns index of matching string?
- Why is this vector iterator not incrementable?
- Why can’t I make a vector of references?
- C++ equivalent of StringBuffer/StringBuilder?
- Displaying contents of a vector container in C++
- Is “delete this” allowed in C++?
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- How to create a dynamic array of integers
- How to create a dynamic array of integers
- Linker Error C++ “undefined reference ” [duplicate]
- How do I build a graphical user interface in C++? [closed]
- C++ convert from 1 char to string?
- How do I build a graphical user interface in C++? [closed]
- convert a char* to std::string
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- How to implement 2D vector array?
- Why the switch statement cannot be applied on strings?
- What is the difference between g++ and gcc?
- How to use setprecision in C++
- How to dynamically allocate arrays in C++
- What does (~0L) mean?
- How to dynamically allocate arrays in C++
- What is the best way to use a HashMap in C++?
- What is the best way to use a HashMap in C++?
- What are the differences between a pointer variable and a reference variable in C++?
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- Sleep for milliseconds
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- Easiest way to convert int to string in C++
- What is the difference between float and double?
- Why is “using namespace std;” considered bad practice?
- outputting ascii table in C++
- What is a lambda expression in C++11?
- Vector of Vectors to create matrix
- How to throw a C++ exception
- std::string to char*
- How to generate a random number in C++?
- pinpointing “conditional jump or move depends on uninitialized value(s)” valgrind message
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- How do I find the length of an array?
- Sleep for milliseconds
- How to convert string to char array in C++?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- What is the effect of extern “C” in C++?
- C++ Cout & Cin & System “Ambiguous” [closed]
- ld: symbol(s) not found for architecture x86_64 error
- C++ string to double conversion
- Why are #ifndef and #define used in C++ header files?
- g++ ld: symbol(s) not found for architecture x86_64
- What exactly is the difference between “pass by reference” in C and in C++?
- How to throw a C++ exception
- Conversion from string to char – c++
- How to find out if an item is present in a std::vector?
- What is meant by Resource Acquisition is Initialization (RAII)?
- When to use extern “C” in simple words? [duplicate]
- What is `CString`?
- Floating point exception( core dump
- Initializing an array of objects
- Passing Arrays to Function in C++
- What does the explicit keyword mean?
- How do I print out the contents of a vector?
- Difference between != and =! with an example(in C++)
- Expression must have class type