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++
- How do I find the length of an array?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- g++ ld: symbol(s) not found for architecture x86_64
- Making my own toString() method on c++ struct
- Struct Constructor in C++?
- How do I iterate over the words of a string?
- C++ Vector of pointers
- error: lvalue required as unary & operand
- What is use of c_str function In c++
- Is there a decent wait function in C++?
- What does T&& (double ampersand) mean in C++11?
- invalid use of non-static member function
- Cannot open include file: ‘stdio.h’ – Visual Studio Community 2017 – C++ Error
- srand(time(0)) and random number generation
- How to convert integer to double implicitly?
- How do I tokenize a string in C++?
- Reverse Contents in Array
- Why would we call cin.clear() and cin.ignore() after reading input?
- Should I learn C before learning C++?
- Comparison with string literal results in unspecified behaviour?
- c++: No instance of overloaded function
- C++ error: Undefined symbols for architecture x86_64
- Visual Studio debugger error: Unable to start program Specified file cannot be found
- What are the most widely used C++ vector/matrix math/linear algebra libraries, and their cost and benefit tradeoffs?
- Insert object at index of vector c++
- Read whole ASCII file into C++ std::string
- Reading getline from cin into a stringstream (C++)
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- C++ int float casting
- How do malloc() and free() work?
- Call to implicitly deleted copy constructor in LLVM
- C++ Linked List Node with class
- What is the use of intptr_t?
- QltAW.png
- std::wstring VS std::string
- Reading string by char till end of line C/C++
- getline: identifier not found
- Colorizing text in the console with C++
- Show two digits after decimal point in c++
- error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- gcc: undefined reference to
- “Field has incomplete type” error
- C++ Returning reference to local variable
- How do I flush the cin buffer?
- Why am I getting the “Expression is not assignable” error?
- template argument deduction/substitution failed, when using std::function and std::bind
- C++ Global variable declaration
- OpenMP set_num_threads() is not working
- What is a null-terminated string?
- Right Justifying output stream in C++
- Serial Port (RS -232) Connection in C++
- invalid use of ‘this’ outside of a non-static member function error?
- Dev C++ compilation error, permission denied
- convert string to size_t
- Use of ‘const’ for function parameters
- What is the difference between the dot (.) operator and -> in C++?
- Different ways to deallocate an array – c++
- How to determine the version of the C++ standard used by the compiler?
- Declare a bit in C++
- Compiler error C4430: missing type specifier – int assumed [duplicate]
- ‘&’ : illegal operation on bound member function expression [duplicate]
- Multiple definitions of “Main”
- Getting the error floating point exception: 8