In the example you gave:
vector<int>::const_iterator it = myvector.begin();
if myvector
isn’t const the non-const version of begin()
will be called and you will be relying on an implicit conversion from iterator to const_iterator.
More Related Contents:
- Template Specialization VS Function Overloading
- Overload a C++ function according to the return value
- Const map element access
- C++ overload resolution [duplicate]
- Functions with const arguments and Overloading
- Top-level const doesn’t influence a function signature
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Why use a const member function?
- vector and const
- STL algorithms: Why no additional interface for containers (additional to iterator pairs)?
- non-const pointer argument to a const double pointer parameter
- Can I use const in vectors to allow adding elements, but not modifications to the already added?
- In which scenario do I use a particular STL container?
- What are the complexity guarantees of the standard containers?
- Purpose of returning by const value? [duplicate]
- problem sorting using member function as comparator
- What kind of optimization does const offer in C/C++?
- How to initialize std::vector from C-style array?
- Case insensitive std::string.find()
- C++ correct way to return pointer to array from function
- I want to convert std::string into a const wchar_t *
- SFINAE works differently in cases of type and non-type template parameters
- what is the best modern c++ approach to construct and manipulate a 2d array [closed]
- Can raw pointers be used instead of iterators with STL algorithms for containers with linear storage?
- C++ overloaded function as template argument
- constexpr const vs constexpr variables?
- std::back_inserter for a std::set?
- C++, can I statically initialize a std::map at compile time?
- How to convert “pointer to pointer type” to const?
- Why can’t C++11 move a noncopyable functor to a std::function?