您可以使用boost::filter_iterator谓词,如:
template< typename T, int N >
struct EveryNth {
bool operator()(const T&) { return m_count++ % N == 0; }
EveryNth() : m_count(0) {}
private:
int m_count;
};
Run Code Online (Sandbox Code Playgroud)