KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to understand how back_inserter work, and this is its implementation that I have from SGI-STL: template<class C> class back_insert_iterator { protected: C* container; public: typedef C container_type; typedef output_iterator_tag iterator_category; typedef void value_type; typedef void difference_type; typedef void pointer; typedef void reference; explicit back_insert_iterator( C& __x ) :container( &__x ) { } back_insert_iterator<C>& operator=( const typename C::value_type& val ) { container->push_back( val ); return *this; } back_insert_iterator<C>& operator*() { return *this; } back_insert_iterator<C>& operator++() { return *this; } back_insert_iterator<C>& operator++( int ) { return *this; } }; I understood most parts, except the last three operator *, ++, ++( int ). My guess for their existence is because they need to support operations when placed inside the STL algorithm. Other than that, I don't know what are they used for? Could anyone help me clarify this? Thanks, Chan
Tags (comma-separated)
Save Edits
Cancel