diff --git a/iterator.hpp b/iterator.hpp index c5bbde62..892ef45c 100644 --- a/iterator.hpp +++ b/iterator.hpp @@ -279,6 +279,22 @@ namespace util { data... ); } -} + + + /////////////////////////////////////////////////////////////////////////// + /// an output iterator that always discards any parameters on assignment. + /// + /// sometimes useful to pass to algorithms that generate useful results as + /// a return value, while not caring about the implicit OutputIterator + /// results. + struct discard_iterator : public std::iterator { + template + void operator= (const T&) { ; } + + discard_iterator& operator++ ( ) { return *this; } + discard_iterator operator++ (int) { return *this; } + discard_iterator& operator* ( ) { return *this; } + }; +}; #endif