Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Example: FlagNth. Here is the classic example from [Sutter02], which is intended to remove the third element from a container v:
class FlagNth {
public:
FlagNth( size_t n ) : current_(0), n_(n) { }
// evaluate to true if and only if this is the n-th invocation
template<typename T>
bool operator()( const T& ) { return ++current_ == n_; } // bad: non-const
private:
size_t current_, n_;
};
// ... later ...
v.erase( remove_if( v.begin(), v.end(), FlagNth(3) ) );