1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
template <class Container>
class back_insert_iterator :
public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container* container;
public:
typedef Container container_type;
explicit back_insert_iterator (Container& x) : container(&x) {}
back_insert_iterator<Container>& operator= (const typename Container::value_type& value)
{ container->push_back(value); return *this; }
back_insert_iterator<Container>& operator= (typename Container::value_type&& value)
{ container->push_back(std::move(value)); return *this; }
back_insert_iterator<Container>& operator* ()
{ return *this; }
back_insert_iterator<Container>& operator++ ()
{ return *this; }
back_insert_iterator<Container> operator++ (int)
{ return *this; }
};
|