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 front_insert_iterator :
public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container* container;
public:
typedef Container container_type;
explicit front_insert_iterator (Container& x) : container(&x) {}
front_insert_iterator<Container>& operator= (const typename Container::value_type& value)
{ container->push_front(value); return *this; }
front_insert_iterator<Container>& operator= (typename Container::value_type&& value)
{ container->push_front(std::move(value)); return *this; }
front_insert_iterator<Container>& operator* ()
{ return *this; }
front_insert_iterator<Container>& operator++ ()
{ return *this; }
front_insert_iterator<Container> operator++ (int)
{ return *this; }
};
| |