Is this correct? It compiles with my compiler but I've been told it doesn't with an AIX one.
typedef std::vector<Entry>::iterator Iterator;
typedef std::vector<Entry>::const_iterator ConstIterator;
bool funct(ConstIterator& iter) const;
inline bool funct(Iterator& iter){return funct(const_cast<ConstIterator&>(iter));}
What should I do to let my code compile on the AIX platform? (Beside reimplement the non const version with Ctrl-C Ctrl-V).
const_castis used to remove const-ness of a variable. That is if you haveconst A& ayou can writeA& b = const_cast<A&>(a). Now you will be able to modifybor call non-const methods on it.In this case you construct a
const_iteratorfrom a regulariteratorand this is always possible even without using aconst_cast. Keep in mind these are two different types and simplyconst_iteratorhappened to be constructable fromiteratorC++ const-ness does not have much to do in this case.