const_iterator
s don’t allow you to change the values that they point to, regular iterator
s do.
As with all things in C++, always prefer const
, unless there’s a good reason to use regular iterators (i.e. you want to use the fact that they’re not const
to change the pointed-to value).
Related Posts:
- List iterator not dereferencable?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- What is meant with “const” at end of function declaration? [duplicate]
- How to navigate through a vector using iterators? (C++)
- How do I erase an element from std::vector<> by index?
- Difference between `constexpr` and `const`
- 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++
- What is the difference between const int*, const int * const, and int const *?
- What is the difference between const int*, const int * const, and int const *?
- How to iterate through a list of objects in C++?
- Difference between const reference and normal parameter
- Pointer to incomplete class type is not allowed
- invalid use of non-static member function
- How to convert a std::string to const char* or char*
- Why use string::iterator rather than index?
- push_back vs emplace_back
- What is the difference between a static and const variable?
- Parsing a comma-delimited std::string
- How can I convert const char* to string and then back to char*?
- How to ensure that a std::map is ordered?
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- How to iterate over a vector?
- push_back vs emplace_back
- C++: Expression must have a constant value when declaring array inside function
- 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
- How to sort with a lambda?
- sorting in std::map where key is a std::string
- How to do std::string indexof in C++ that returns index of matching string?
- non-member function cannot have cv-qualifier
- Why is this vector iterator not incrementable?
- Where to declare/define class scope constants in C++?
- Use of ‘const’ for function parameters
- Why can’t I make a vector of references?
- C++ equivalent of StringBuffer/StringBuilder?
- Displaying contents of a vector container in C++
- Pause Console in C++ program
- Why the switch statement cannot be applied on strings?
- How to dynamically allocate arrays in C++
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- Why is “using namespace std;” considered bad practice?
- What is a lambda expression in C++11?
- How to convert string to char array in C++?
- how to implement quick sort algorithm in C++
- C++ Vector of pointers
- Is there a C++ decompiler?
- What is a dangling pointer?
- undefined reference to WinMain@16 (codeblocks)
- Why am I getting this redefinition of class error?
- C++ forbids converting a `string` constant to `char*` – Alphabets to Morse converting program
- What is activation record in the context of C and C++?
- Static array vs. dynamic array in C++
- C++ terminate called after throwing an instance of ‘std::out_of_range’ Simple Averaging code
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- Why doesn’t std::vector::push_front() exist?
- Fastest way to check if a file exist using standard C++/C++11,14,17/C?
- Invalid use of non-static member function c++
- How to dynamically allocate an array of pointers in C++?
- How do I compile C++ to JavaScript in a browser?
- Is the sizeof(some pointer) always equal to four?
- How do you initialise a dynamic array in C++?
- What are the distinctions between the various symbols (*,&, etc) combined with parameters?
- Accessors and Mutators C++
- What is the difference between .cc and .cpp file suffix?
- C++ error: object of abstract class type is not allowed: pure virtual function has no overrider
- Correct way to work with vector of arrays
- What’s the difference between nexti and stepi in gdb?
- Resizing dynamic array in c++
- C++ – Nested include – Avoiding ‘include nested too deeply error’
- c++ error c2015: too many characters in constant
- Splitting a C++ std::string using tokens, e.g. “;”
- Py_Initialize fails – unable to load the file system codec
- C++ pass an array by reference
- error LNK2019: unresolved external symbol “” referenced in function
- Undefined reference to a static member
- How do I deal with “signed/unsigned mismatch” warnings (C4018)?
- Creating folders in C++
- Unrecognizable template declaration/definition
- MSVCP120d.dll missing
- Update g++ but still old version
- module unsafe for SAFESEH image C++
- Why are there two different getline() functions (if indeed there are)?
- Whats the difference between UInt8 and uint8_t
- Struct with template variables in C++
- error: no member function declared in class