iterator: add the OutputIterator "discard_iterator"

This commit is contained in:
Danny Robson 2017-08-01 13:31:47 +10:00
parent 6c77393a2c
commit 523c7c7e38

View File

@ -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<std::output_iterator_tag, discard_iterator> {
template <typename T>
void operator= (const T&) { ; }
discard_iterator& operator++ ( ) { return *this; }
discard_iterator operator++ (int) { return *this; }
discard_iterator& operator* ( ) { return *this; }
};
};
#endif